summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-19 21:18:19 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2016-02-19 21:18:19 +0000
commit611942f2d737cc75c7492dffc183174e432aa155 (patch)
tree29917c92395cf81ab9e10f8a66b92e78e3ee605f /src/plugins/platforms/windows
parent9b49b375e3d753fa3cd8166da266724a85cfe389 (diff)
parent4fe2fbcf827ae6bec976b0b8dcaa5d14bd05dc33 (diff)
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp42
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp43
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp2
9 files changed, 65 insertions, 53 deletions
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
index b2cd5b124b..b265054e12 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
@@ -162,7 +162,7 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion &region)
if (QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha)
m_alphaNeedsFill = true;
else // upgrade but here we know app painting does not rely on alpha hence no need to fill
- format = qt_alphaVersionForPainting(format);
+ format = qt_maybeAlphaVersionWithSameDepth(format);
QWindowsNativeImage *oldwni = m_image.data();
QWindowsNativeImage *newwni = new QWindowsNativeImage(size.width(), size.height(), format);
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index 5c2610a3fe..a13fe5c40e 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -148,8 +148,8 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
QScopedArrayPointer<uchar> xMask(new uchar[height * n]);
int x = 0;
for (int i = 0; i < height; ++i) {
- const uchar *bits = bbits.scanLine(i);
- const uchar *mask = mbits.scanLine(i);
+ const uchar *bits = bbits.constScanLine(i);
+ const uchar *mask = mbits.constScanLine(i);
for (int j = 0; j < n; ++j) {
uchar b = bits[j];
uchar m = mask[j];
@@ -179,8 +179,8 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
x += sysN;
} else {
int fillWidth = n > sysN ? sysN : n;
- const uchar *bits = bbits.scanLine(i);
- const uchar *mask = mbits.scanLine(i);
+ const uchar *bits = bbits.constScanLine(i);
+ const uchar *mask = mbits.constScanLine(i);
for (int j = 0; j < fillWidth; ++j) {
uchar b = bits[j];
uchar m = mask[j];
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index da28b5b19b..704f99c4ef 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -996,7 +996,7 @@ EGLConfig QWindowsEGLContext::chooseConfig(const QSurfaceFormat &format)
QVector<EGLConfig> configs(matching);
QWindowsEGLStaticContext::libEGL.eglChooseConfig(display, configureAttributes.constData(), configs.data(), configs.size(), &matching);
if (!cfg && matching > 0)
- cfg = configs.first();
+ cfg = configs.constFirst();
EGLint red = 0;
EGLint green = 0;
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 2d5eb4b4b9..dde85f2e6a 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -877,14 +877,13 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
static const int SMOOTH_SCALABLE = 0xffff;
const QString foundryName; // No such concept.
- const NEWTEXTMETRIC *tm = (NEWTEXTMETRIC *)textmetric;
- const bool fixed = !(tm->tmPitchAndFamily & TMPF_FIXED_PITCH);
- const bool ttf = (tm->tmPitchAndFamily & TMPF_TRUETYPE);
- const bool scalable = tm->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
- const int size = scalable ? SMOOTH_SCALABLE : tm->tmHeight;
- const QFont::Style style = tm->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
+ const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH);
+ const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
+ const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
+ const int size = scalable ? SMOOTH_SCALABLE : textmetric->tmHeight;
+ const QFont::Style style = textmetric->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
const bool antialias = false;
- const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(tm->tmWeight);
+ const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(textmetric->tmWeight);
const QFont::Stretch stretch = QFont::Unstretched;
#ifndef QT_NO_DEBUG_OUTPUT
@@ -964,18 +963,21 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
return true;
}
-static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
- int type, LPARAM registerAlias)
+static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
+ DWORD type, LPARAM lParam)
{
+ const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
const uchar charSet = f->elfLogFont.lfCharSet;
+ const bool registerAlias = bool(lParam);
- const FONTSIGNATURE signature = textmetric->ntmFontSig;
-
- // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is
- // identical to a TEXTMETRIC except for the last four members, which we don't use
- // anyway
- addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type, registerAlias);
+ // NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according
+ // to the documentation is identical to a TEXTMETRIC except for the last four
+ // members, which we don't use anyway
+ const FONTSIGNATURE *signature = Q_NULLPTR;
+ if (type & TRUETYPE_FONTTYPE)
+ signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
+ addFontToDatabase(familyName, charSet, textmetric, signature, type, registerAlias);
// keep on enumerating
return 1;
@@ -994,7 +996,7 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName, bool regist
familyName.toWCharArray(lf.lfFaceName);
lf.lfFaceName[familyName.size()] = 0;
lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, (LPARAM)registerAlias, 0);
+ EnumFontFamiliesEx(dummy, &lf, storeFont, LPARAM(registerAlias), 0);
ReleaseDC(0, dummy);
}
@@ -1015,9 +1017,11 @@ struct PopulateFamiliesContext
};
} // namespace
-static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *tm, int, LPARAM lparam)
+static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
+ DWORD, LPARAM lparam)
{
// the "@family" fonts are just the same as "family". Ignore them.
+ const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
const QString faceName = QString::fromWCharArray(faceNameW);
@@ -1027,7 +1031,7 @@ static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICE
context->seenSystemDefaultFont = true;
// Register current font's english name as alias
- const bool ttf = (tm->ntmTm.tmPitchAndFamily & TMPF_TRUETYPE);
+ const bool ttf = textmetric->tmPitchAndFamily & TMPF_TRUETYPE;
if (ttf && localizedName(faceName)) {
const QString englishName = getEnglishName(faceName);
if (!englishName.isEmpty()) {
@@ -1051,7 +1055,7 @@ void QWindowsFontDatabase::populateFontDatabase()
lf.lfFaceName[0] = 0;
lf.lfPitchAndFamily = 0;
PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
+ EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
ReleaseDC(0, dummy);
// Work around EnumFontFamiliesEx() not listing the system font.
if (!context.seenSystemDefaultFont)
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
index 8b61379c42..fb75e75dcd 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
@@ -396,14 +396,13 @@ static bool addFontToDatabase(const QString &faceName,
static const int SMOOTH_SCALABLE = 0xffff;
const QString foundryName; // No such concept.
- const NEWTEXTMETRIC *tm = (NEWTEXTMETRIC *)textmetric;
- const bool fixed = !(tm->tmPitchAndFamily & TMPF_FIXED_PITCH);
- const bool ttf = (tm->tmPitchAndFamily & TMPF_TRUETYPE);
- const bool scalable = tm->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
- const int size = scalable ? SMOOTH_SCALABLE : tm->tmHeight;
- const QFont::Style style = tm->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
+ const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH);
+ const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
+ const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
+ const int size = scalable ? SMOOTH_SCALABLE : textmetric->tmHeight;
+ const QFont::Style style = textmetric->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
const bool antialias = false;
- const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(tm->tmWeight);
+ const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(textmetric->tmWeight);
const QFont::Stretch stretch = QFont::Unstretched;
#ifndef QT_NO_DEBUG_STREAM
@@ -520,19 +519,21 @@ static QByteArray getFntTable(HFONT hfont, uint tag)
}
#endif
-static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
- int type, LPARAM)
+static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
+ DWORD type, LPARAM)
{
-
+ const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const QString faceName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
const QString fullName = QString::fromWCharArray(f->elfFullName);
const uchar charSet = f->elfLogFont.lfCharSet;
- const FONTSIGNATURE signature = textmetric->ntmFontSig;
- // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is
- // identical to a TEXTMETRIC except for the last four members, which we don't use
- // anyway
- addFontToDatabase(faceName, fullName, charSet, (TEXTMETRIC *)textmetric, &signature, type, false);
+ // NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according
+ // to the documentation is identical to a TEXTMETRIC except for the last four
+ // members, which we don't use anyway
+ const FONTSIGNATURE *signature = Q_NULLPTR;
+ if (type & TRUETYPE_FONTTYPE)
+ signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
+ addFontToDatabase(faceName, fullName, charSet, textmetric, signature, type, false);
// keep on enumerating
return 1;
@@ -559,7 +560,7 @@ void QWindowsFontDatabaseFT::populateFamily(const QString &familyName)
familyName.toWCharArray(lf.lfFaceName);
lf.lfFaceName[familyName.size()] = 0;
lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, 0, 0);
+ EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0);
ReleaseDC(0, dummy);
}
@@ -579,17 +580,20 @@ struct PopulateFamiliesContext
// Delayed population of font families
-static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *tm, int, LPARAM lparam)
+static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
+ DWORD, LPARAM lparam)
{
+ const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
// the "@family" fonts are just the same as "family". Ignore them.
const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
// Register only font families for which a font file exists for delayed population
+ const bool ttf = textmetric->tmPitchAndFamily & TMPF_TRUETYPE;
const QString faceName = QString::fromWCharArray(faceNameW);
const FontKey *key = findFontKey(faceName);
if (!key) {
key = findFontKey(QString::fromWCharArray(f->elfFullName));
- if (!key && (tm->ntmTm.tmPitchAndFamily & TMPF_TRUETYPE) && localizedName(faceName))
+ if (!key && ttf && localizedName(faceName))
key = findFontKey(getEnglishName(faceName));
}
if (key) {
@@ -599,7 +603,6 @@ static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICE
context->seenSystemDefaultFont = true;
// Register current font's english name as alias
- const bool ttf = (tm->ntmTm.tmPitchAndFamily & TMPF_TRUETYPE);
if (ttf && localizedName(faceName)) {
const QString englishName = getEnglishName(faceName);
if (!englishName.isEmpty()) {
@@ -623,7 +626,7 @@ void QWindowsFontDatabaseFT::populateFontDatabase()
lf.lfFaceName[0] = 0;
lf.lfPitchAndFamily = 0;
PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
+ EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
ReleaseDC(0, dummy);
// Work around EnumFontFamiliesEx() not listing the system font
if (!context.seenSystemDefaultFont)
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index 1b88f8bbe4..160560dbda 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -1181,11 +1181,11 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
for (int y=0; y<mask->height(); ++y) {
uchar *dest = alphaMap.scanLine(y);
if (mask->image().format() == QImage::Format_RGB16) {
- const qint16 *src = (qint16 *) ((const QImage &) mask->image()).scanLine(y);
+ const qint16 *src = reinterpret_cast<const qint16 *>(mask->image().constScanLine(y));
for (int x=0; x<mask->width(); ++x)
dest[x] = 255 - qGray(src[x]);
} else {
- const uint *src = (uint *) ((const QImage &) mask->image()).scanLine(y);
+ const uint *src = reinterpret_cast<const uint *>(mask->image().constScanLine(y));
for (int x=0; x<mask->width(); ++x) {
if (QWindowsNativeImage::systemFormat() == QImage::Format_RGB16)
dest[x] = 255 - qGray(src[x]);
@@ -1230,7 +1230,7 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra
QImage rgbMask(mask->width(), mask->height(), QImage::Format_RGB32);
for (int y=0; y<mask->height(); ++y) {
uint *dest = (uint *) rgbMask.scanLine(y);
- const uint *src = (uint *) source.scanLine(y);
+ const uint *src = reinterpret_cast<const uint *>(source.constScanLine(y));
for (int x=0; x<mask->width(); ++x) {
dest[x] = 0xffffffff - (0x00ffffff & src[x]);
}
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
index 02b56fc40a..2831962ef4 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
@@ -499,7 +499,7 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub
QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
for (int y=0; y<im.height(); ++y) {
- uint *src = (uint*) im.scanLine(y);
+ const uint *src = reinterpret_cast<const uint *>(im.constScanLine(y));
uchar *dst = alphaMap.scanLine(y);
for (int x=0; x<im.width(); ++x) {
*dst = 255 - (m_fontEngineData->pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.);
@@ -765,12 +765,17 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph
transform.m21 = matrix.m21();
transform.m22 = matrix.m22();
+ DWRITE_RENDERING_MODE renderMode =
+ fontDef.hintingPreference == QFont::PreferNoHinting
+ ? DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
+ : DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
+
IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
HRESULT hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
&glyphRun,
1.0f,
&transform,
- DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC,
+ renderMode,
DWRITE_MEASURING_MODE_NATURAL,
0.0, 0.0,
&glyphAnalysis
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index 61c867cf07..79f627d458 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -181,8 +181,8 @@ static bool qt_write_dibv5(QDataStream &s, QImage image)
memset(buf, 0, bpl_bmp);
for (int y=image.height()-1; y>=0; y--) {
// write the image bits
- QRgb *p = (QRgb *)image.scanLine(y);
- QRgb *end = p + image.width();
+ const QRgb *p = reinterpret_cast<const QRgb *>(image.constScanLine(y));
+ const QRgb *end = p + image.width();
b = buf;
while (p < end) {
int alpha = qAlpha(*p);
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 464fcc886f..c78a2a3105 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -189,7 +189,7 @@ static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
return QPoint(0, 0);
const QWindowsScreenManager &screenManager = QWindowsContext::instance()->screenManager();
const QWindowsScreen *screen = screenManager.screens().size() == 1
- ? screenManager.screens().first() : screenManager.screenAtDp(point);
+ ? screenManager.screens().constFirst() : screenManager.screenAtDp(point);
if (screen)
return screen->availableGeometry().topLeft() - screen->geometry().topLeft();
#else