summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-11-08 09:11:01 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-11-08 09:11:15 +0100
commitdd1bb0de7b141c3f37068b49b0181ec829dc1aee (patch)
treed984a3298f5dff4cc4af339bf83e91630186c458 /src/gui
parentf0a43a9def456784fd9408e3026d6689c8b715c1 (diff)
parent78c687f98eabb3da00026ac2375cdb4bb5770a0a (diff)
Merge "Merge remote-tracking branch 'origin/5.14' into 5.15"
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimage.cpp25
-rw-r--r--src/gui/image/qimage_conversions.cpp69
-rw-r--r--src/gui/image/qimage_p.h23
-rw-r--r--src/gui/image/qimageiohandler.cpp4
-rw-r--r--src/gui/image/qimageiohandler.h2
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp20
-rw-r--r--src/gui/text/qfont.cpp7
-rw-r--r--src/gui/text/qfontdatabase.cpp3
-rw-r--r--src/gui/text/qtextmarkdownimporter.cpp24
-rw-r--r--src/gui/text/qtextmarkdownwriter.cpp3
10 files changed, 107 insertions, 73 deletions
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 760f831889..4f3821a7cc 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;
}
@@ -2143,9 +2156,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
@@ -2171,10 +2184,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>,
@@ -2424,9 +2437,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
@@ -2451,10 +2464,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>,
@@ -2807,9 +2820,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
@@ -2834,10 +2847,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
@@ -2913,9 +2926,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
@@ -2940,10 +2953,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);
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;
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 76548d5d86..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,14 +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.
- QVariant byIndex = screen->screen()->property(scaleFactorProperty);
- 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;
}
}
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 76fde5388c..bf130fa0b7 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;
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 261e1d831b..67702ab5b5 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -731,7 +731,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;
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
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());