From fe97ecf408da60931fc49b502a223d59b5f93f99 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Jun 2016 14:03:22 +0200 Subject: Make it possible to create distance fields with any height Assuming a certain max height for glyphs would make it impossible to render certain fonts. The follow up to this change is in Qt Quick, where the code must also be adapted to make it work. Task-number: QTBUG-52389 Change-Id: Iabebb2de21a92d1537b2965aa6603529c1d5d587 Reviewed-by: Yoann Lopes --- src/gui/text/qdistancefield.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 6a7019bc3c..c493ca1dad 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -799,8 +799,9 @@ QDistanceFieldData *QDistanceFieldData::create(const QPainterPath &path, bool do { int dfMargin = QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution); int glyphWidth = qCeil(path.boundingRect().width() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2; + int glyphHeight = qCeil(path.boundingRect().height() / QT_DISTANCEFIELD_SCALE(doubleResolution)) + dfMargin * 2; - QDistanceFieldData *data = create(QSize(glyphWidth, QT_DISTANCEFIELD_TILESIZE(doubleResolution))); + QDistanceFieldData *data = create(QSize(glyphWidth, glyphHeight)); makeDistanceField(data, path, -- cgit v1.2.3 From c2d3c2b9f97cd842f2cbcc28acbc7a140b45222f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 10 Jun 2016 13:38:31 +0200 Subject: Fix crash when creating distance field for large glyph Do the multiplication of the normal components in floating point to avoid integer overflows. Also add an assert, since a scale of 0 here will cause a normal of (0, 0) which will assert further into the drawRectangle() function, and the cause is not immediately clear. Task-number: QTBUG-51956 Change-Id: If7187d56af28eaa149f8f362050a587da5adb262 Reviewed-by: Yoann Lopes --- src/gui/text/qdistancefield.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index c493ca1dad..efe4cc9928 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -544,7 +544,9 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path QPoint n(to.y() - from.y(), from.x() - to.x()); if (n.x() == 0 && n.y() == 0) continue; - int scale = qRound((offs << 16) / qSqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16 + int scale = qRound((offs << 16) / qSqrt(qreal(n.x()) * n.x() + qreal(n.y()) * n.y())); // 8:16 + Q_ASSERT(scale != 0); + n.rx() = n.x() * scale >> 8; n.ry() = n.y() * scale >> 8; normals.append(n); -- cgit v1.2.3 From e85e7f4b81b285efa5875a3ebf239d2f7f4523d7 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 13 Jun 2016 13:36:38 +0200 Subject: Fixed developer build for MinGW 0 must not be used as a null pointer constant Change-Id: I082d0e99c105fb02980b9cf390e7f6e4c9ad0869 Reviewed-by: Thiago Macieira --- src/gui/image/qimage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index d05044c44b..97c191c6c4 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -315,7 +315,7 @@ public: static QImage::Format toImageFormat(QPixelFormat format) Q_DECL_NOTHROW; #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED inline QString text(const char* key, const char* lang=0) const; + QT_DEPRECATED inline QString text(const char *key, const char *lang = Q_NULLPTR) const; QT_DEPRECATED inline QList textList() const; QT_DEPRECATED inline QStringList textLanguages() const; QT_DEPRECATED inline QString text(const QImageTextKeyLang&) const; -- cgit v1.2.3 From 5eda3cff5e18308f8d78d438e5aeb4e685c5f974 Mon Sep 17 00:00:00 2001 From: Palo Kisa Date: Fri, 20 May 2016 15:08:00 +0200 Subject: QIconLoader: Fix typo in directoryMatchesSize() For QIconDirInfo::Scalable directories condition for directoryMatchesSize was mistyped. In particular only the minSize was considered which could lead to false positive checks. [ChangeLog][QtGui][QIconLoaderEngine] Fixed theme lookup for scalable entries Change-Id: Ic7e06cc0a2e4be69e6633847cef8c2c5686378ea Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/image/qiconloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 3ead72dfbb..c7f1f2beb4 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -403,7 +403,7 @@ static bool directoryMatchesSize(const QIconDirInfo &dir, int iconsize) return dir.size == iconsize; } else if (dir.type == QIconDirInfo::Scalable) { - return dir.size <= dir.maxSize && + return iconsize <= dir.maxSize && iconsize >= dir.minSize; } else if (dir.type == QIconDirInfo::Threshold) { -- cgit v1.2.3 From c165cbaef2ccff52225836baf3c3db64ebe128dc Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Jun 2016 14:05:16 +0200 Subject: Remove unused macro: QT_DISTANCEFIELD_DEFAULT_TILESIZE Usage of this macro has been removed, and so can the macro. Task-number: QTBUG-52389 Change-Id: I28a5459e577b78f0f9907612893d6850848f405d Reviewed-by: Yoann Lopes --- src/gui/text/qdistancefield_p.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h index c376e93abe..85662d6ca6 100644 --- a/src/gui/text/qdistancefield_p.h +++ b/src/gui/text/qdistancefield_p.h @@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE #define QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE 54 -#define QT_DISTANCEFIELD_DEFAULT_TILESIZE 64 #define QT_DISTANCEFIELD_DEFAULT_SCALE 16 #define QT_DISTANCEFIELD_DEFAULT_RADIUS 80 #define QT_DISTANCEFIELD_HIGHGLYPHCOUNT 2000 @@ -60,9 +59,6 @@ QT_BEGIN_NAMESPACE #define QT_DISTANCEFIELD_BASEFONTSIZE(NarrowOutlineFont) \ (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2 : \ QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE) -#define QT_DISTANCEFIELD_TILESIZE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_TILESIZE * 2 : \ - QT_DISTANCEFIELD_DEFAULT_TILESIZE) #define QT_DISTANCEFIELD_SCALE(NarrowOutlineFont) \ (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_SCALE / 2 : \ QT_DISTANCEFIELD_DEFAULT_SCALE) -- cgit v1.2.3 From c2b7841843f05fe902e6a94aee2c3f33b169009e Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 7 Jun 2016 16:52:13 +0200 Subject: Finally fix crash in inplace-modified data-constructed images Avoid all inplace modification of images using external data buffers. Since the QImage methods are documented to create a (modified) copy, there is afterwards no API requirement on the lifetime of the data buffer. This patch supersedes 509bc7e59c69937900cf258e64889a6e88edbcf0 Task-number: QTBUG-53721 Change-Id: I3ccc01619eb61d8630104449394e0b76df0af695 Reviewed-by: Friedemann Kleint Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/image/qimage.cpp | 6 +++++- src/gui/image/qimage_conversions.cpp | 19 +++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 59a83a6750..d9f9c1a7ad 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3115,6 +3115,8 @@ void QImage::mirrored_inplace(bool horizontal, bool vertical) return; detach(); + if (!d->own_data) + *this = copy(); do_mirror(d, d, horizontal, vertical); } @@ -3261,6 +3263,8 @@ void QImage::rgbSwapped_inplace() return; detach(); + if (!d->own_data) + *this = copy(); switch (d->format) { case Format_Invalid: @@ -4745,7 +4749,7 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla return true; // No in-place conversion if we have to detach - if (ref.load() > 1 || ro_data) + if (ref.load() > 1 || !own_data) return false; InPlace_Image_Converter converter = qimage_inplace_converter_map[format][newFormat]; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index cc79e73534..7b8d88ba72 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -763,8 +763,8 @@ static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConver static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -817,8 +817,8 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -868,8 +868,7 @@ static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversi static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags flags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); if (data->has_alpha_clut) { for (int i = 0; i < data->colortable.size(); ++i) @@ -886,8 +885,8 @@ static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversio static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -943,8 +942,8 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_RGB32); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; -- cgit v1.2.3