From d894cfa863a3fc9cd9a6dcb9f3c7b04e6ce41285 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Wed, 4 Nov 2015 11:35:09 +0200 Subject: Fix QImage::setDotsPerMeterX/Y for images with some orientations Rotation of images with orientation of 90 and 270 degrees dropped DPM values from rotated image. Task-number: QTBUG-49220 Change-Id: I9c23153c49dd63b5f6958fdde72f466873b0a407 Reviewed-by: Friedemann Kleint Reviewed-by: Liang Qi Reviewed-by: aavit --- src/gui/image/qimage.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gui') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index c4691b5f5e..b3d8563614 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4285,6 +4285,8 @@ QImage QImage::smoothScaled(int w, int h) const { static QImage rotated90(const QImage &image) { QImage out(image.height(), image.width(), image.format()); + out.setDotsPerMeterX(image.dotsPerMeterY()); + out.setDotsPerMeterY(image.dotsPerMeterX()); if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); @@ -4353,6 +4355,8 @@ static QImage rotated180(const QImage &image) { static QImage rotated270(const QImage &image) { QImage out(image.height(), image.width(), image.format()); + out.setDotsPerMeterX(image.dotsPerMeterY()); + out.setDotsPerMeterY(image.dotsPerMeterX()); if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); -- cgit v1.2.3 From 0e1f3aab11a4310595d8651c02ce5f9d60c93252 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 2 Nov 2015 08:28:14 +0400 Subject: Update Unicode data & algorithms up to v8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Georgian lari currency symbol * A large collection of CJK unified ideographs * Emoji symbols and symbol modifiers * Letters to support the Ik language in Uganda, Kulango in the Côte d’Ivoire, and other languages of Africa * A set of lowercase Cherokee syllables, forming case pairs with the existing Cherokee characters * The Ahom script for support of the Tai Ahom language in India * Arabic letters to support Arwi—the Tamil language written in the Arabic script For more details, see http://www.unicode.org/versions/Unicode8.0.0/ [ChangeLog][QtCore] Unicode data updated to v.8.0 Change-Id: If255f95c9c45655b721369a116299da3cabbba0a Reviewed-by: Lars Knoll --- src/gui/text/qharfbuzzng.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index 102c62ea8a..b2edfc00a0 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -188,7 +188,15 @@ static const hb_script_t _qtscript_to_hbscript[] = { HB_SCRIPT_SIDDHAM, HB_SCRIPT_KHUDAWADI, HB_SCRIPT_TIRHUTA, - HB_SCRIPT_WARANG_CITI + HB_SCRIPT_WARANG_CITI, + + // Unicode 8.0 additions + HB_SCRIPT_AHOM, + HB_SCRIPT_ANATOLIAN_HIEROGLYPHS, + HB_SCRIPT_HATRAN, + HB_SCRIPT_MULTANI, + HB_SCRIPT_OLD_HUNGARIAN, + HB_SCRIPT_SIGNWRITING }; Q_STATIC_ASSERT(QChar::ScriptCount == sizeof(_qtscript_to_hbscript) / sizeof(_qtscript_to_hbscript[0])); -- cgit v1.2.3 From 9f66b1dd71f5802d99a3478aaf13c87af136a3b6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 21 Aug 2015 09:41:23 +0200 Subject: Set private inline QRgba64 methods always inline By setting them always inline we ensure they will never generate symbols. Change-Id: I2c815c4fe2cb498187656e0b25ef4499258885ff Reviewed-by: Erik Verbruggen --- src/gui/painting/qrgba64.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h index 264ec394cd..fab9506ff2 100644 --- a/src/gui/painting/qrgba64.h +++ b/src/gui/painting/qrgba64.h @@ -161,12 +161,12 @@ public: } private: - static Q_DECL_CONSTEXPR quint64 alphaMask() { return Q_UINT64_C(0xffff) << AlphaShift; } + static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE quint64 alphaMask() { return Q_UINT64_C(0xffff) << AlphaShift; } - static Q_DECL_CONSTEXPR uint div_257_floor(uint x) { return (x - (x >> 8)) >> 8; } - static Q_DECL_CONSTEXPR uint div_257(uint x) { return div_257_floor(x + 128); } - static Q_DECL_CONSTEXPR uint div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; } - Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied_32bit() const + static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint div_257_floor(uint x) { return (x - (x >> 8)) >> 8; } + static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint div_257(uint x) { return div_257_floor(x + 128); } + static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; } + Q_DECL_RELAXED_CONSTEXPR Q_ALWAYS_INLINE QRgba64 unpremultiplied_32bit() const { if (isOpaque() || isTransparent()) return *this; @@ -176,7 +176,7 @@ private: const quint16 b = (quint32(blue()) * 0xffff + a/2) / a; return fromRgba64(r, g, b, a); } - Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied_64bit() const + Q_DECL_RELAXED_CONSTEXPR Q_ALWAYS_INLINE QRgba64 unpremultiplied_64bit() const { if (isOpaque() || isTransparent()) return *this; -- cgit v1.2.3 From 6f84d50457ad6c8864e776fc722895458350c2e1 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 11 Nov 2015 14:58:22 +0100 Subject: move styleOverride from QApplicationPrivate to QGuiApplicationPrivate * -style option is also used in other cases than widget world Change-Id: I8555d309a7b9df0d26ad7a7b930411260537180e Reviewed-by: J-P Nurmi --- src/gui/kernel/qguiapplication.cpp | 10 ++++++++++ src/gui/kernel/qguiapplication_p.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 216537e51a..c5762fe1ee 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -127,6 +127,8 @@ Qt::MouseButtons QGuiApplicationPrivate::tabletState = Qt::NoButton; QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; +QString QGuiApplicationPrivate::styleOverride; + Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; bool QGuiApplicationPrivate::highDpiScalingUpdated = false; @@ -1256,6 +1258,7 @@ void QGuiApplicationPrivate::init() session_key = QString::fromWCharArray(guidstr); # endif #endif + QString s; int j = argc ? 1 : 0; for (int i=1; i Date: Wed, 11 Nov 2015 15:32:29 +0100 Subject: Make qt_findAtNxFile return the source device pixel ratio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QTextImageHandler needs it. And QQuickImageBase will also need it. Change-Id: Ica5d17519c4c6c06e25bab7d2b1d3733f4058425 Reviewed-by: Tor Arne Vestbø --- src/gui/image/qicon.cpp | 11 +++++++++-- src/gui/image/qicon.h | 3 ++- src/gui/text/qtextimagehandler.cpp | 20 ++++++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index af3af516db..b2d9ed18f5 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1378,8 +1378,12 @@ QDebug operator<<(QDebug dbg, const QIcon &i) Given base foo.png and a target dpr of 2.5, this function will look for foo@3x.png, then foo@2x, then fall back to foo.png if not found. + + \a sourceDevicePixelRatio will be set to the value of N if the argument is + a non-null pointer */ -QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio) +QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, + qreal *sourceDevicePixelRatio) { if (targetDevicePixelRatio <= 1.0) return baseFileName; @@ -1397,8 +1401,11 @@ QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRati for (int n = qCeil(targetDevicePixelRatio); n > 1; --n) { QString atNxfileName = baseFileName; atNxfileName.insert(dotIndex, atNx.arg(n)); - if (QFile::exists(atNxfileName)) + if (QFile::exists(atNxfileName)) { + if (sourceDevicePixelRatio) + *sourceDevicePixelRatio = n; return atNxfileName; + } } return baseFileName; diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 8c72f54629..9ed7336502 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -139,7 +139,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QIcon &); #endif -Q_GUI_EXPORT QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio); +Q_GUI_EXPORT QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, + qreal *sourceDevicePixelRatio = Q_NULLPTR); QT_END_NAMESPACE diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp index 747ed90281..16d81a7d6d 100644 --- a/src/gui/text/qtextimagehandler.cpp +++ b/src/gui/text/qtextimagehandler.cpp @@ -44,8 +44,10 @@ QT_BEGIN_NAMESPACE -extern QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio); -static QString resolveFileName(QString fileName, QUrl *url, qreal targetDevicePixelRatio) +extern QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, + qreal *sourceDevicePixelRatio); +static QString resolveFileName(QString fileName, QUrl *url, qreal targetDevicePixelRatio, + qreal *sourceDevicePixelRatio) { // We might use the fileName for loading if url loading fails // try to make sure it is a valid file path. @@ -64,7 +66,7 @@ static QString resolveFileName(QString fileName, QUrl *url, qreal targetDevicePi return fileName; // try to find a Nx version - return qt_findAtNxFile(fileName, targetDevicePixelRatio); + return qt_findAtNxFile(fileName, targetDevicePixelRatio, sourceDevicePixelRatio); } @@ -76,7 +78,8 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con if (name.startsWith(QLatin1String(":/"))) // auto-detect resources and convert them to url name.prepend(QLatin1String("qrc")); QUrl url = QUrl(name); - name = resolveFileName(name, &url, devicePixelRatio); + qreal sourcePixelRatio = 1.0; + name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio); const QVariant data = doc->resource(QTextDocument::ImageResource, url); if (data.type() == QVariant::Pixmap || data.type() == QVariant::Image) { pm = qvariant_cast(data); @@ -102,7 +105,7 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con } if (name.contains(QStringLiteral("@2x"))) - pm.setDevicePixelRatio(2.0); + pm.setDevicePixelRatio(sourcePixelRatio); return pm; } @@ -157,7 +160,8 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format, const if (name.startsWith(QLatin1String(":/"))) // auto-detect resources name.prepend(QLatin1String("qrc")); QUrl url = QUrl(name); - name = resolveFileName(name, &url, devicePixelRatio); + qreal sourcePixelRatio = 1.0; + name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio); const QVariant data = doc->resource(QTextDocument::ImageResource, url); if (data.type() == QVariant::Image) { image = qvariant_cast(data); @@ -181,8 +185,8 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format, const doc->addResource(QTextDocument::ImageResource, url, image); } - if (name.contains(QStringLiteral("@2x"))) - image.setDevicePixelRatio(2.0); + if (sourcePixelRatio != 1.0) + image.setDevicePixelRatio(sourcePixelRatio); return image; } -- cgit v1.2.3 From 0f336e85655fd50cf84b67cf9101e92bba1efbfc Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 7 Nov 2015 00:26:03 +0400 Subject: Introduce png_dependency.pri Just like any other x_dependency.pri, it shall be included instead of linking with png lib directly. Change-Id: I698c8a8137f937d2e2c5f5dc9b9188b780c9e49a Reviewed-by: Oswald Buddenhagen Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/image/qpnghandler.pri | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qpnghandler.pri b/src/gui/image/qpnghandler.pri index 9ab175d628..505d214130 100644 --- a/src/gui/image/qpnghandler.pri +++ b/src/gui/image/qpnghandler.pri @@ -1,9 +1,4 @@ HEADERS += $$PWD/qpnghandler_p.h SOURCES += $$PWD/qpnghandler.cpp -contains(QT_CONFIG, system-png) { - if(unix|mingw): LIBS_PRIVATE += -lpng - else:win32: LIBS += libpng.lib -} else { - include($$PWD/../../3rdparty/libpng.pri) -} +include($$PWD/../../3rdparty/png_dependency.pri) -- cgit v1.2.3 From 2316db05a89c7de6a10ac64e0860262b25ed2a31 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 7 Nov 2015 09:53:56 +0400 Subject: QFontEngine: Check for AAT support only with HB-NG HB-old is unable to handle these anyways. Change-Id: Ibe69b5d030134b8a0a76dc966b6dfc6b5ff9a883 Reviewed-by: Lars Knoll --- src/gui/text/qfontengine.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index a0eedee6b9..3208a199b7 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -370,17 +370,15 @@ bool QFontEngine::supportsScript(QChar::Script script) const return true; } -#ifdef Q_OS_MAC - { +#ifdef QT_ENABLE_HARFBUZZ_NG + if (qt_useHarfbuzzNG()) { +#if defined(Q_OS_DARWIN) // in AAT fonts, 'gsub' table is effectively replaced by 'mort'/'morx' table uint len; if (getSfntTableData(MAKE_TAG('m','o','r','t'), 0, &len) || getSfntTableData(MAKE_TAG('m','o','r','x'), 0, &len)) return true; - } #endif -#ifdef QT_ENABLE_HARFBUZZ_NG - if (qt_useHarfbuzzNG()) { bool ret = false; if (hb_face_t *face = hb_qt_face_get_for_engine(const_cast(this))) { hb_tag_t script_tag_1, script_tag_2; -- cgit v1.2.3 From 50af66293de8bd5dd9fd9141a45d9415b5c688aa Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 7 Nov 2015 09:54:21 +0400 Subject: QTextEngine: Do not disable graphite2 HB shaper backend This fixes-up bf013c9e745c63cb112be4d3a37027ff997927dd by specifying graphite2 shaper in a "safe" shaper list, one used for non-CoreText font engines (currently, FreeType font engine only). Make the the comment and the code a bit cleaner about the fallback shaper list. Change-Id: Ib0cedc0b593023c9ee771e8e98c314d9c8f13037 Reviewed-by: Lars Knoll --- src/gui/text/qtextengine.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 6b98c14205..530871f65b 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1120,15 +1120,6 @@ QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE -#if defined(Q_OS_OSX) && !defined(QT_NO_FREETYPE) -static const char *s_shapersForOsxFreeType[] = -{ - "ot", - "fallback", - Q_NULLPTR -}; -#endif - int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector &itemBoundaries, bool kerningEnabled) const { uint glyphs_shaped = 0; @@ -1182,13 +1173,21 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st const int num_features = 1; const char *const *shaper_list = Q_NULLPTR; -#if defined(Q_OS_OSX) && !defined(QT_NO_FREETYPE) - // What's behind QFontEngine::FaceData::user_data isn't compatible between CoreText and - // FreeType font engines - specifically functions in hb-coretext.cc would run into undefined - // behavior with data from the FreeType engine. The OpenType shaper works with that engine. - if (actualFontEngine->type() == QFontEngine::Freetype) - shaper_list = s_shapersForOsxFreeType; +#if defined(Q_OS_DARWIN) + // What's behind QFontEngine::FaceData::user_data isn't compatible between different font engines + // - specifically functions in hb-coretext.cc would run into undefined behavior with data + // from non-CoreText engine. The other shapers works with that engine just fine. + if (actualFontEngine->type() != QFontEngine::Mac) { + static const char *s_shaper_list_without_coretext[] = { + "graphite2", + "ot", + "fallback", + Q_NULLPTR + }; + shaper_list = s_shaper_list_without_coretext; + } #endif + bool shapedOk = hb_shape_full(hb_font, buffer, features, num_features, shaper_list); if (Q_UNLIKELY(!shapedOk)) { hb_buffer_destroy(buffer); -- cgit v1.2.3 From c1da13f6db756a9b23c46193304156c5e10f3bc1 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 7 Nov 2015 09:54:46 +0400 Subject: QTextEngine: Apply CoreText specific post-processing for QFE::Mac only These tricks has no meaning to other font engines (i.e. to FreeType). Change-Id: I0410693d4d159367d760433062506691dc7c4610 Reviewed-by: Lars Knoll --- src/gui/text/qtextengine.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 530871f65b..50a242d81e 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1267,19 +1267,20 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st g.glyphs[i] |= (engineIdx << 24); } -#ifdef Q_OS_MAC - // CTRunGetPosition has a bug which applies matrix on 10.6, so we disable - // scaling the advances for this particular version - if (actualFontEngine->fontDef.stretch != 100 - && QSysInfo::MacintoshVersion != QSysInfo::MV_10_6) { - QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100); - for (uint i = 0; i < num_glyphs; ++i) - g.advances[i] *= stretch; - } - - if (actualFontEngine->fontDef.styleStrategy & QFont::ForceIntegerMetrics) { - for (uint i = 0; i < num_glyphs; ++i) - g.advances[i] = g.advances[i].round(); +#ifdef Q_OS_DARWIN + if (actualFontEngine->type() == QFontEngine::Mac) { + // CTRunGetPosition has a bug which applies matrix on 10.6, so we disable + // scaling the advances for this particular version + if (QSysInfo::MacintoshVersion != QSysInfo::MV_10_6 && actualFontEngine->fontDef.stretch != 100) { + QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100); + for (uint i = 0; i < num_glyphs; ++i) + g.advances[i] *= stretch; + } + + if (actualFontEngine->fontDef.styleStrategy & QFont::ForceIntegerMetrics) { + for (uint i = 0; i < num_glyphs; ++i) + g.advances[i] = g.advances[i].round(); + } } #endif -- cgit v1.2.3 From 26e66694fad4f3ec1afba2f2c1de3c66c6d3d7ac Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sun, 8 Nov 2015 11:44:57 +0400 Subject: QFontEngineFT: Minor optimization to convertGRAYToARGB() Precalculate everything we can and use faster loop. Make inlined as it is used just in a single place. Change-Id: If3c33d60739eb4ce896020321442ae81edd1c13d Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/text/qfontengine_ft.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 0d28785aa1..162f409acd 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -590,13 +590,16 @@ static void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int heigh } } -static void convertGRAYToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch) { - for (int y = 0; y < height; ++y) { - int readpos = (y * src_pitch); - int writepos = (y * width); - for (int x = 0; x < width; ++x) { - dst[writepos + x] = (0xFF << 24) + (src[readpos + x] << 16) + (src[readpos + x] << 8) + src[readpos + x]; +static inline void convertGRAYToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch) +{ + while (height--) { + const uchar *p = src; + const uchar * const e = p + width; + while (p < e) { + uchar gray = *p++; + *dst++ = (0xFF << 24) | (gray << 16) | (gray << 8) | gray; } + src += src_pitch; } } -- cgit v1.2.3 From a856c4a902816a7d691ca50e6f556521287be441 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 27 Oct 2015 11:00:35 +0100 Subject: Fix falsely reported style for fallback font In change 8f6b3284106fa11129e4fa6e5ec3adc6cb1f489f we override the fontDef of the fallback font with the fontDef of the original font (with the family name replaced) to fix a regression where boldness was not inherited by the fallback font. This caused a bug, though, since the contents of the fontDef would now misrepresent the actual font used. The side effect of this was that isSmoothlyScalable() returned false because the family and styleName combination we claim to have did not exist in the font database. Result: We fell back to native rendering for the font even though it's scalable. Weight and style are the only parts that should be inherited, since they are synthesized. So rather than overwriting the fontDef completely, we copy the weight and style when needed. The bug in QTBUG-42963 is still fixed after this change. [ChangeLog][Text] Fixed problem where fallback fonts for text with certain styles would be reported as unscalable. Change-Id: I95ef67f818852aea5a6ae8df789a52364ecb59a6 Task-number: QTBUG-47547 Reviewed-by: Lars Knoll Reviewed-by: Konstantin Ritt --- src/gui/text/qfontengine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 3208a199b7..f267b2d147 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1835,7 +1835,10 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) request.family = fallbackFamilyAt(at - 1); if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)) { - engine->fontDef = request; + if (request.weight > QFont::Normal) + engine->fontDef.weight = request.weight; + if (request.style > QFont::StyleNormal) + engine->fontDef.style = request.style; return engine; } -- cgit v1.2.3 From 6a7155997bfbc909c9875198a93dc2a6cba75795 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 9 Nov 2015 01:21:24 +0400 Subject: QFontEngineFT: Revise the legacy LCD filter implementation Use an optimized version of the intra-pixel filter found in FreeType's _ft_lcd_filter_legacy(). Gives us somewhat better accuracy and better performance. Change-Id: Id4200b67e6ff55f605037c3e5464fef8bb03fbde Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_ft.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 162f409acd..242dd84096 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -534,25 +534,18 @@ QFontEngineFT::Glyph::~Glyph() delete [] data; } -static const uint subpixel_filter[3][3] = { - { 180, 60, 16 }, - { 38, 180, 38 }, - { 16, 60, 180 } -}; - -static inline uint filterPixel(uint red, uint green, uint blue, bool legacyFilter) +static inline uint filterPixel(uchar red, uchar green, uchar blue, bool legacyFilter) { - uint res; if (legacyFilter) { - uint high = (red*subpixel_filter[0][0] + green*subpixel_filter[0][1] + blue*subpixel_filter[0][2]) >> 8; - uint mid = (red*subpixel_filter[1][0] + green*subpixel_filter[1][1] + blue*subpixel_filter[1][2]) >> 8; - uint low = (red*subpixel_filter[2][0] + green*subpixel_filter[2][1] + blue*subpixel_filter[2][2]) >> 8; - res = (mid << 24) + (high << 16) + (mid << 8) + low; - } else { - uint alpha = green; - res = (alpha << 24) + (red << 16) + (green << 8) + blue; + uint r = red, g = green, b = blue; + // intra-pixel filter used by the legacy filter (adopted from _ft_lcd_filter_legacy) + red = (r * uint(65538 * 9/13) + g * uint(65538 * 1/6) + b * uint(65538 * 1/13)) / 65536; + green = (r * uint(65538 * 3/13) + g * uint(65538 * 4/6) + b * uint(65538 * 3/13)) / 65536; + blue = (r * uint(65538 * 1/13) + g * uint(65538 * 1/6) + b * uint(65538 * 9/13)) / 65536; } - return res; + + // alpha = green + return (green << 24) + (red << 16) + (green << 8) + blue; } static void convertRGBToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr, bool legacyFilter) @@ -563,9 +556,9 @@ static void convertRGBToARGB(const uchar *src, uint *dst, int width, int height, while (h--) { uint *dd = dst; for (int x = 0; x < w; x += 3) { - uint red = src[x+1-offs]; - uint green = src[x+1]; - uint blue = src[x+1+offs]; + uchar red = src[x + 1 - offs]; + uchar green = src[x + 1]; + uchar blue = src[x + 1 + offs]; *dd = filterPixel(red, green, blue, legacyFilter); ++dd; } @@ -580,9 +573,9 @@ static void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int heigh const int offs = bgr ? -src_pitch : src_pitch; while (h--) { for (int x = 0; x < width; x++) { - uint red = src[x+src_pitch-offs]; - uint green = src[x+src_pitch]; - uint blue = src[x+src_pitch+offs]; + uchar red = src[x + src_pitch - offs]; + uchar green = src[x + src_pitch]; + uchar blue = src[x + src_pitch + offs]; dst[x] = filterPixel(red, green, blue, legacyFilter); } dst += width; -- cgit v1.2.3 From 4d5b57825a2ec5eb15ab8a40bb173306e2279914 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 9 Nov 2015 01:47:07 +0400 Subject: QFontEngineFT: Optimize format convertion code with template magic Avoids in-loop check for every pixel by costs of slightly bigger code. Change-Id: I8321d0945ac6b677786431670b2316c60e4db492 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/text/qfontengine_ft.cpp | 54 +++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 16 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 242dd84096..8dfabd48ad 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -534,55 +534,77 @@ QFontEngineFT::Glyph::~Glyph() delete [] data; } -static inline uint filterPixel(uchar red, uchar green, uchar blue, bool legacyFilter) +struct LcdFilterDummy { - if (legacyFilter) { + static inline void filterPixel(uchar &, uchar &, uchar &) + {} +}; + +struct LcdFilterLegacy +{ + static inline void filterPixel(uchar &red, uchar &green, uchar &blue) + { uint r = red, g = green, b = blue; // intra-pixel filter used by the legacy filter (adopted from _ft_lcd_filter_legacy) red = (r * uint(65538 * 9/13) + g * uint(65538 * 1/6) + b * uint(65538 * 1/13)) / 65536; green = (r * uint(65538 * 3/13) + g * uint(65538 * 4/6) + b * uint(65538 * 3/13)) / 65536; blue = (r * uint(65538 * 1/13) + g * uint(65538 * 1/6) + b * uint(65538 * 9/13)) / 65536; } +}; - // alpha = green - return (green << 24) + (red << 16) + (green << 8) + blue; -} - -static void convertRGBToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr, bool legacyFilter) +template +static void convertRGBToARGB_helper(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr) { - int h = height; const int offs = bgr ? -1 : 1; const int w = width * 3; - while (h--) { + while (height--) { uint *dd = dst; for (int x = 0; x < w; x += 3) { uchar red = src[x + 1 - offs]; uchar green = src[x + 1]; uchar blue = src[x + 1 + offs]; - *dd = filterPixel(red, green, blue, legacyFilter); - ++dd; + LcdFilter::filterPixel(red, green, blue); + // alpha = green + *dd++ = (green << 24) | (red << 16) | (green << 8) | blue; } dst += width; src += src_pitch; } } -static void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr, bool legacyFilter) +static inline void convertRGBToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr, bool legacyFilter) +{ + if (!legacyFilter) + convertRGBToARGB_helper(src, dst, width, height, src_pitch, bgr); + else + convertRGBToARGB_helper(src, dst, width, height, src_pitch, bgr); +} + +template +static void convertRGBToARGB_V_helper(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr) { - int h = height; const int offs = bgr ? -src_pitch : src_pitch; - while (h--) { + while (height--) { for (int x = 0; x < width; x++) { uchar red = src[x + src_pitch - offs]; uchar green = src[x + src_pitch]; uchar blue = src[x + src_pitch + offs]; - dst[x] = filterPixel(red, green, blue, legacyFilter); + LcdFilter::filterPixel(red, green, blue); + // alpha = green + *dst++ = (green << 24) | (red << 16) | (green << 8) | blue; } - dst += width; src += 3*src_pitch; } } +static inline void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr, bool legacyFilter) +{ + if (!legacyFilter) + convertRGBToARGB_V_helper(src, dst, width, height, src_pitch, bgr); + else + convertRGBToARGB_V_helper(src, dst, width, height, src_pitch, bgr); +} + static inline void convertGRAYToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch) { while (height--) { -- cgit v1.2.3 From d2792d2ed90e1e2789aa80f1667d6e67cd35af66 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 30 Oct 2015 15:58:10 +0100 Subject: Fix screenForGeometry on a corner case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QRect only deals with integers, and I had a window set on the corner and without a size. When this screen was created, it was reported to be on the wrong screen, thus created there wrong. The reason for this is that ::center is not prepared for this use. QRect(QPoint(500,500), QSize()).center() is QRect(499, 499) Change-Id: I24e57182f84873306f180749e96368d6da1147a9 Reviewed-by: Paul Olav Tvete Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformwindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index ea3b75c81c..8757715c0d 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -484,7 +484,9 @@ QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) co { QPlatformScreen *currentScreen = screen(); QPlatformScreen *fallback = currentScreen; - QPoint center = newGeometry.center(); + //QRect::center can return a value outside the rectangle if it's empty + const QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center(); + if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) { Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) { if (screen->geometry().contains(center)) -- cgit v1.2.3 From 1378e7af1de3c0133e277ec3832ccd72e7286e67 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 16 Nov 2015 14:06:42 -0800 Subject: qdrawhelper.cpp: Fix constexpr build with MSVC 2015 Update 1 error C2397: conversion from 'uint' to 'uchar' requires a narrowing conversion Change-Id: Ic1b9e0a78b2faa5a0ae4e6de33ab2ee4b654af5f Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/painting/qdrawhelper.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 5c1cd8adef..52843fa113 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -379,9 +379,9 @@ static const uint *QT_FASTCALL convertARGBPMFromARGB32PM(uint *buffer, const uin template Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutRGB() { return QPixelLayout{ - redWidth(), redShift(), - greenWidth(), greenShift(), - blueWidth(), blueShift(), + uchar(redWidth()), uchar(redShift()), + uchar(greenWidth()), uchar(greenShift()), + uchar(blueWidth()), uchar(blueShift()), 0, 0, false, bitsPerPixel(), convertToRGB32, @@ -394,10 +394,10 @@ template Q_DECL_CONSTEXPR static inline QPixelLayout pixe template Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutARGBPM() { return QPixelLayout{ - redWidth(), redShift(), - greenWidth(), greenShift(), - blueWidth(), blueShift(), - alphaWidth(), alphaShift(), + uchar(redWidth()), uchar(redShift()), + uchar(greenWidth()), uchar(greenShift()), + uchar(blueWidth()), uchar(blueShift()), + uchar(alphaWidth()), uchar(alphaShift()), true, bitsPerPixel(), convertARGBPMToARGB32PM, convertARGBPMFromARGB32PM, -- cgit v1.2.3