QWindowsFontDatabase: port local QSets to QDuplicateTracker
Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. Change-Id: I155f5518190c5f8f6d21fbec3fcecd6bcc7ff852 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
0edda211f9
commit
09fba5cf36
@ -51,6 +51,7 @@
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QtEndian>
|
||||
#include <QtCore/private/qduplicatetracker_p.h>
|
||||
#include <QtCore/private/qsystemlibrary_p.h>
|
||||
#include <QtCore/private/qwinregistry_p.h>
|
||||
|
||||
@ -499,7 +500,7 @@ namespace {
|
||||
{}
|
||||
|
||||
QString populatedFontFamily;
|
||||
QSet<FontAndStyle> foundFontAndStyles;
|
||||
QDuplicateTracker<FontAndStyle> foundFontAndStyles;
|
||||
QWindowsFontDatabase *windowsFontDatabase;
|
||||
};
|
||||
}
|
||||
@ -642,10 +643,8 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
|
||||
signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
|
||||
// We get a callback for each script-type supported, but we register them all
|
||||
// at once using the signature, so we only need one call to addFontToDatabase().
|
||||
FontAndStyle fontAndStyle = {familyName, styleName};
|
||||
if (sfp->foundFontAndStyles.contains(fontAndStyle))
|
||||
if (sfp->foundFontAndStyles.hasSeen({familyName, styleName}))
|
||||
return 1;
|
||||
sfp->foundFontAndStyles.insert(fontAndStyle);
|
||||
}
|
||||
addFontToDatabase(familyName, styleName, *logFont, textmetric, signature, type, sfp);
|
||||
|
||||
|
@ -51,6 +51,8 @@
|
||||
#if QT_CONFIG(regularexpression)
|
||||
#include <QtCore/QRegularExpression>
|
||||
#endif
|
||||
#include <QtCore/private/qduplicatetracker_p.h>
|
||||
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QFontDatabase>
|
||||
|
||||
@ -318,11 +320,9 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
|
||||
signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
|
||||
// We get a callback for each script-type supported, but we register them all
|
||||
// at once using the signature, so we only need one call to addFontToDatabase().
|
||||
QSet<FontAndStyle> *foundFontAndStyles = reinterpret_cast<QSet<FontAndStyle> *>(lparam);
|
||||
FontAndStyle fontAndStyle = {faceName, styleName};
|
||||
if (foundFontAndStyles->contains(fontAndStyle))
|
||||
auto foundFontAndStyles = reinterpret_cast<QDuplicateTracker<FontAndStyle> *>(lparam);
|
||||
if (foundFontAndStyles->hasSeen({faceName, styleName}))
|
||||
return 1;
|
||||
foundFontAndStyles->insert(fontAndStyle);
|
||||
}
|
||||
addFontToDatabase(faceName, styleName, fullName, *logFont, textmetric, signature, type);
|
||||
|
||||
@ -352,7 +352,7 @@ void QWindowsFontDatabaseFT::populateFamily(const QString &familyName)
|
||||
lf.lfFaceName[familyName.size()] = 0;
|
||||
lf.lfCharSet = DEFAULT_CHARSET;
|
||||
lf.lfPitchAndFamily = 0;
|
||||
QSet<FontAndStyle> foundFontAndStyles;
|
||||
QDuplicateTracker<FontAndStyle> foundFontAndStyles;
|
||||
EnumFontFamiliesEx(dummy, &lf, storeFont, reinterpret_cast<intptr_t>(&foundFontAndStyles), 0);
|
||||
ReleaseDC(0, dummy);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user