From d86192e5ba7911407881f5079c4486c1fb084dc6 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Sat, 26 Oct 2019 13:57:05 +0200 Subject: QFontDatabase: improve logging output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Log the style name, add more descriptions of what's being logged. Before: Adding font "Lucida Grande" 50 QFont::StyleNormal 0 aa true fixed false After: Adding font family "Lucida Grande" stylename "Regular" weight 50 style QFont::StyleNormal pixelSize 0 antialiased true fixed false Change-Id: I138f1b9f41dc41c528c830d81f8018fc16561631 Reviewed-by: Tor Arne Vestbø --- src/gui/text/qfontdatabase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index fe7dd80e44..67783e5b42 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -733,7 +733,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; -- cgit v1.2.3 From 0fb995492d377fde96b453680f3604f5991171c0 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 27 Oct 2019 09:33:54 +0100 Subject: QImageIOHandler: remove #if around virtual method name() It makes -DQT_DISABLE_DEPRECATED_BEFORE=0x050d00 (in an application) trigger a binary incompatible change and crash. Change-Id: I9b9783d134821697180dc3fd8f2f69a51ddb7ac6 Reviewed-by: Christian Ehrlicher Reviewed-by: Edward Welbourne --- src/gui/image/qimageiohandler.cpp | 4 +--- src/gui/image/qimageiohandler.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'src/gui') 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; -- cgit v1.2.3 From accc40f323b2eb284a9c2767a29659ebbb135b14 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 30 Oct 2019 14:45:47 +0100 Subject: Fix check for EGL on INTEGRITY This fixes a regression introduced in c00487d588f. Fixes: QTBUG-79285 Change-Id: I95f073d019d6e909f8de132ea9f27002043d5d52 Reviewed-by: Kimmo Ollila Reviewed-by: Timo Aarnipuro Reviewed-by: Tasuku Suzuki Reviewed-by: Joerg Bornemann --- src/gui/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/configure.json b/src/gui/configure.json index c2793bf236..19312d245d 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1375,7 +1375,7 @@ }, "egl": { "label": "EGL", - "condition": "(features.opengl || features.openvg) && (features.angle || libs.egl) && (features.dlopen || !config.unix)", + "condition": "(features.opengl || features.openvg) && (features.angle || libs.egl) && (features.dlopen || !config.unix || config.integrity)", "output": [ "privateFeature", "feature" ] }, "egl_x11": { -- cgit v1.2.3 From a3361ac66d5f8929530c1507b14bae7e398247a6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 4 Nov 2019 16:09:49 +0100 Subject: Remove old resizing inplace QImage converters They are highly unlikely to avoid reallocating and moving data, and working inplace is likely just slower. Change-Id: I16eb1d54a660e52b145be1ed0b64a3fb636a0002 Reviewed-by: Thiago Macieira --- src/gui/image/qimage_conversions.cpp | 220 +---------------------------------- 1 file changed, 5 insertions(+), 215 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 9e1df7058c..760f831889 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -819,216 +819,6 @@ static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConver return true; } -static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) -{ - Q_ASSERT(data->format == QImage::Format_Indexed8); - Q_ASSERT(data->own_data); - - const int depth = 32; - auto params = QImageData::calculateImageParameters(data->width, data->height, depth); - if (params.bytesPerLine < 0) - return false; - uchar *const newData = (uchar *)realloc(data->data, params.totalSize); - if (!newData) - return false; - - data->data = newData; - - // start converting from the end because the end image is bigger than the source - uchar *src_data = newData + data->nbytes; // end of src - quint32 *dest_data = (quint32 *) (newData + params.totalSize); // end of dest > end of src - const int width = data->width; - const int src_pad = data->bytes_per_line - width; - const int dest_pad = (params.bytesPerLine >> 2) - width; - if (data->colortable.size() == 0) { - data->colortable.resize(256); - for (int i = 0; i < 256; ++i) - data->colortable[i] = qRgb(i, i, i); - } else { - for (int i = 0; i < data->colortable.size(); ++i) - data->colortable[i] = qPremultiply(data->colortable.at(i)); - - // Fill the rest of the table in case src_data > colortable.size() - const int oldSize = data->colortable.size(); - const QRgb lastColor = data->colortable.at(oldSize - 1); - data->colortable.insert(oldSize, 256 - oldSize, lastColor); - } - - for (int i = 0; i < data->height; ++i) { - src_data -= src_pad; - dest_data -= dest_pad; - for (int pixI = 0; pixI < width; ++pixI) { - --src_data; - --dest_data; - *dest_data = data->colortable.at(*src_data); - } - } - - data->colortable = QVector(); - data->format = QImage::Format_ARGB32_Premultiplied; - data->bytes_per_line = params.bytesPerLine; - data->depth = depth; - data->nbytes = params.totalSize; - - return true; -} - -static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags) -{ - Q_ASSERT(data->format == QImage::Format_Indexed8); - Q_ASSERT(data->own_data); - - const int depth = 32; - auto params = QImageData::calculateImageParameters(data->width, data->height, depth); - if (params.bytesPerLine < 0) - return false; - uchar *const newData = (uchar *)realloc(data->data, params.totalSize); - if (!newData) - return false; - - data->data = newData; - - // start converting from the end because the end image is bigger than the source - uchar *src_data = newData + data->nbytes; - quint32 *dest_data = (quint32 *) (newData + params.totalSize); - const int width = data->width; - const int src_pad = data->bytes_per_line - width; - const int dest_pad = (params.bytesPerLine >> 2) - width; - if (data->colortable.size() == 0) { - data->colortable.resize(256); - for (int i = 0; i < 256; ++i) - data->colortable[i] = qRgb(i, i, i); - } else { - // Fill the rest of the table in case src_data > colortable.size() - const int oldSize = data->colortable.size(); - const QRgb lastColor = data->colortable.at(oldSize - 1); - data->colortable.insert(oldSize, 256 - oldSize, lastColor); - } - - for (int i = 0; i < data->height; ++i) { - src_data -= src_pad; - dest_data -= dest_pad; - for (int pixI = 0; pixI < width; ++pixI) { - --src_data; - --dest_data; - *dest_data = (quint32) data->colortable.at(*src_data); - } - } - - data->colortable = QVector(); - data->format = QImage::Format_ARGB32; - data->bytes_per_line = params.bytesPerLine; - data->depth = depth; - data->nbytes = params.totalSize; - - return true; -} - -static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags flags) -{ - Q_ASSERT(data->format == QImage::Format_Indexed8); - Q_ASSERT(data->own_data); - - if (data->has_alpha_clut) { - for (int i = 0; i < data->colortable.size(); ++i) - data->colortable[i] |= 0xff000000; - } - - if (!convert_indexed8_to_ARGB_inplace(data, flags)) - return false; - - data->format = QImage::Format_RGB32; - return true; -} - -static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) -{ - Q_ASSERT(data->format == QImage::Format_Indexed8); - Q_ASSERT(data->own_data); - - const int depth = 16; - auto params = QImageData::calculateImageParameters(data->width, data->height, depth); - if (params.bytesPerLine < 0) - return false; - uchar *const newData = (uchar *)realloc(data->data, params.totalSize); - if (!newData) - return false; - - data->data = newData; - - // start converting from the end because the end image is bigger than the source - uchar *src_data = newData + data->nbytes; - quint16 *dest_data = (quint16 *) (newData + params.totalSize); - const int width = data->width; - const int src_pad = data->bytes_per_line - width; - const int dest_pad = (params.bytesPerLine >> 1) - width; - - quint16 colorTableRGB16[256]; - const int tableSize = data->colortable.size(); - if (tableSize == 0) { - for (int i = 0; i < 256; ++i) - colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i)); - } else { - // 1) convert the existing colors to RGB16 - for (int i = 0; i < tableSize; ++i) - colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i)); - data->colortable = QVector(); - - // 2) fill the rest of the table in case src_data > colortable.size() - const quint16 lastColor = colorTableRGB16[tableSize - 1]; - for (int i = tableSize; i < 256; ++i) - colorTableRGB16[i] = lastColor; - } - - for (int i = 0; i < data->height; ++i) { - src_data -= src_pad; - dest_data -= dest_pad; - for (int pixI = 0; pixI < width; ++pixI) { - --src_data; - --dest_data; - *dest_data = colorTableRGB16[*src_data]; - } - } - - data->format = QImage::Format_RGB16; - data->bytes_per_line = params.bytesPerLine; - data->depth = depth; - data->nbytes = params.totalSize; - - return true; -} - -static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) -{ - Q_ASSERT(data->format == QImage::Format_RGB32); - Q_ASSERT(data->own_data); - - const int depth = 16; - - // cannot overflow, since we're shrinking the buffer - const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qsizetype src_bytes_per_line = data->bytes_per_line; - quint32 *src_data = (quint32 *) data->data; - quint16 *dst_data = (quint16 *) data->data; - - for (int i = 0; i < data->height; ++i) { - for (int j = 0; j < data->width; ++j) - dst_data[j] = qConvertRgb32To16(src_data[j]); - src_data = (quint32 *) (((char*)src_data) + src_bytes_per_line); - dst_data = (quint16 *) (((char*)dst_data) + dst_bytes_per_line); - } - data->format = QImage::Format_RGB16; - data->bytes_per_line = dst_bytes_per_line; - data->depth = depth; - data->nbytes = dst_bytes_per_line * data->height; - uchar *const newData = (uchar *)realloc(data->data, data->nbytes); - if (newData) - data->data = newData; - - // can't fail, since we're shrinking - return true; -} - static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src) { Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied || src->format == QImage::Format_RGBA8888_Premultiplied); @@ -2978,10 +2768,10 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, - convert_indexed8_to_RGB_inplace, - convert_indexed8_to_ARGB_inplace, - convert_indexed8_to_ARGB_PM_inplace, - convert_indexed8_to_RGB16_inplace, + 0, + 0, + 0, + 0, 0, 0, 0, @@ -3005,7 +2795,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, mask_alpha_converter_inplace, mask_alpha_converter_inplace, - convert_RGB_to_RGB16_inplace, + 0, 0, 0, 0, -- cgit v1.2.3 From b1004c7d0a5d7abbacd687fd41a5b2683e62b27d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 29 Oct 2019 09:44:50 +0100 Subject: If only family is set, prefer that in the families list after resolving If a font with only a family set is resolved with one that has been setup with setFamilies() then the family needs to be prepended to the families list after resolving. This is so that the font still prefers the one set as just a family with no famillies set. This also amends the QFontDialog test to account for this too. [ChangeLog][QtGui][Text] Resolving a font that just has a family set with families set will prepend the family to the families so that it is still the first preference for the font. Task-number: QTBUG-46322 Change-Id: Icc4005732f95b2b4c684e592b06b31e133270e44 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfont.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 84c5be60b1..f5dbec3a3e 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; -- cgit v1.2.3 From 524ab7b5357e66b935a42956ec365a511e62e5ed Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 4 Oct 2019 22:06:41 +0200 Subject: Avoid crashing when the end of an empty markdown list is detected The markdown parser generates empty lists in some cases when a character that can be used as a bullet is found on a line by itself. cbEnterBlock() and cbLeaveBlock() are called symmetrically in such cases. QStack::pop() on an empty stack triggers an assert, so push and pop need to be done symmetrically too. But it's difficult to actually create the list as soon as the MD_BLOCK_UL or MD_BLOCK_OL callback occurs, without breaking the case fixed in 7224d0e427d71e559b928c44634839b4791c1416 (and probably other cases). That's because QTextCursor::insertList() creates a list item at the same time as it creates the list itself, and also inherits block formatting from the previous block. We now insert empty lists with empty items whenever the need for that is detected though, and there's a failsafe to prevent popping in case something still goes wrong with that logic. We aren't strict about reproducing the original markdown when regenerating it via toMarkdown(), but it's getting closer. Fixes: QTBUG-78870 Change-Id: Ided194ce7aec2710c60dbac42761ee4169ed9b78 Reviewed-by: Edward Welbourne Reviewed-by: Robert Loehning --- src/gui/text/qtextmarkdownimporter.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/gui') 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(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(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(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 -- cgit v1.2.3 From d1c6f7e5a2e0ee6c50bbf0668e44200bd8469a09 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 14 Oct 2019 17:59:16 +0200 Subject: QTextMarkdownWriter: preserve empty lists You can save a "skeletal" document with list items to fill in later, the same as you can do in HTML or ODF format. Reading them back via QTextDocument::fromMarkdown() isn't always perfect though. Fixes: QTBUG-79217 Change-Id: Iacdb3e6792250ebdead05f314c9e3d00546eeb9f Reviewed-by: Shawn Rutledge --- src/gui/text/qtextmarkdownwriter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') 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()); -- cgit v1.2.3 From 5771b5325b85f71a8f8ff78ed13eaee3df2e3ba8 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 5 Nov 2019 22:10:24 +0100 Subject: syncqt: Add a means to suspend/resume the processing of a file Rather than tweaking the parser to cover every eventuality with corner case lines that could cause incorrect header files to be created then the means to suspend/resume the processing of a file is added. This enables us to have it skip over the template line that is causing a QList header to be created as part of the QtGui headers. This patch includes the fix to solve this in addition. Fixes: QTBUG-68129 Change-Id: I751646c4b20a4434347c149ae5e6dcb6e7618853 Reviewed-by: Joerg Bornemann --- src/gui/kernel/qevent.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 2b1c6a6e31..0a8a1925e7 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -827,7 +827,14 @@ private: qint64 m_numericId; }; Q_DECLARE_TYPEINFO(QPointingDeviceUniqueId, Q_MOVABLE_TYPE); + +#if 0 +#pragma qt_sync_suspend_processing +#endif template <> class QList {}; // to prevent instantiation: use QVector instead +#if 0 +#pragma qt_sync_resume_processing +#endif Q_GUI_EXPORT bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW; inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW -- cgit v1.2.3 From b7858e9b4bdb2866f0c76ecaa8dd25bd9b618afc Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 9 Oct 2019 15:24:08 +0200 Subject: Add QPlatformPlaceholderScreen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...and QPlatformScreen::isPlaceholder() This class can be used to reduce the amount of boiler-plate required to create a fake screen when there are no real screens (Qt doesn't currently support running with no QScreens). Change-Id: I7290406a3d010bcbaf15a1a8a84216e3abf75c78 Reviewed-by: Tor Arne Vestbø Reviewed-by: Paul Olav Tvete --- src/gui/kernel/qplatformscreen.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index d7378aed51..e27355a940 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -105,6 +105,8 @@ public: QPlatformScreen(); virtual ~QPlatformScreen(); + virtual bool isPlaceholder() const { return false; }; + virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; virtual QRect geometry() const = 0; @@ -172,6 +174,16 @@ private: friend class QScreenPrivate; }; +// Qt doesn't currently support running with no platform screen +// QPA plugins can use this class to create a fake screen +class QPlatformPlaceholderScreen : public QPlatformScreen { + bool isPlaceholder() const override { return true; }; + QRect geometry() const override { return QRect(); } + QRect availableGeometry() const override { return QRect(); } + int depth() const override { return 32; } + QImage::Format format() const override { return QImage::Format::Format_RGB32; } +}; + QT_END_NAMESPACE #endif // QPLATFORMSCREEN_H -- cgit v1.2.3 From ed20f3209804d865804f9eb14c3fcfb4b7941140 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Fri, 25 Oct 2019 14:47:15 +0200 Subject: QHighDpiScaling: fix potential null pointer dereference It's not guaranteed that QPlatformScreen::screen should always return a valid pointer. Furthermore, you can run into this situation with, for example, two screens setup. Task-number: QTBUG-53022 Change-Id: Ic23bb2c30b1245f98a793a44cc5e0b39f9afac4b Reviewed-by: Friedemann Kleint --- src/gui/kernel/qhighdpiscaling.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 76548d5d86..704dcee633 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -657,7 +657,8 @@ 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 qScreen = screen->screen(); + auto byIndex = qScreen ? qScreen->property(scaleFactorProperty) : QVariant(); auto byNameIt = qNamedScreenScaleFactors()->constFind(screen->name()); if (byIndex.isValid()) { screenPropertyUsed = true; -- cgit v1.2.3 From 52a3f1b00cca13767eefabf61742d2d802c56511 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 6 Nov 2019 10:04:54 +0100 Subject: Fix accuracy of ARGB32->A2RGB30 conversions It was converted over ARGB32PM, when it should have been directly converted to not lose accuracy, instead there was an unnecessary direct ARGB32->RGB30 conversion, which was converted to the necessary type. This also improves the selection of conversion over ARGB32PM or RGBA64PM for ARGB32 and RGBA8888 by using 32-bit conversion when alpha is not relevant. Change-Id: I5990d8a23b2909d3910d8c1213fa46477742b052 Reviewed-by: Eirik Aavitsland --- src/gui/image/qimage.cpp | 25 ++----------- src/gui/image/qimage_conversions.cpp | 69 +++++++++++++++++++++--------------- src/gui/image/qimage_p.h | 23 ++++++++++++ 3 files changed, 67 insertions(+), 50 deletions(-) (limited to 'src/gui') 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 9e1df7058c..97a5f89e68 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 -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(c); + const uint alpha = (qAlpha(c) >> 6) * 85; + c = BYTE_MUL(c, alpha); + *dest_data = (qConvertRgb32ToRgb30(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 -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(c); + const uint alpha = (qAlpha(c) >> 6) * 85; + c = BYTE_MUL(c, alpha); + *rgb_data = (qConvertRgb32ToRgb30(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; } @@ -2353,9 +2366,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - convert_RGB_to_RGB30, 0, - convert_RGB_to_RGB30, + 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -2381,10 +2394,10 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_ARGB_to_RGBx, convert_ARGB_to_RGBA, 0, - convert_RGB_to_RGB30, 0, - convert_RGB_to_RGB30, + convert_ARGB_to_A2RGB30, 0, + convert_ARGB_to_A2RGB30, 0, 0, 0, convert_ARGB32_to_RGBA64, @@ -2634,9 +2647,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, convert_passthrough, convert_passthrough, - convert_RGB_to_RGB30, 0, - convert_RGB_to_RGB30, + 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -2661,10 +2674,10 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat mask_alpha_converter_RGBx, 0, 0, - convert_RGB_to_RGB30, 0, - convert_RGB_to_RGB30, + convert_ARGB_to_A2RGB30, 0, + convert_ARGB_to_A2RGB30, 0, 0, 0, convert_ARGB32_to_RGBA64, @@ -3017,9 +3030,9 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, - convert_RGB_to_RGB30_inplace, 0, - convert_RGB_to_RGB30_inplace, + 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -3044,10 +3057,10 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_ARGB_to_RGBA_inplace, convert_ARGB_to_RGBA_inplace, 0, - convert_RGB_to_RGB30_inplace, 0, - convert_RGB_to_RGB30_inplace, + convert_ARGB_to_A2RGB30_inplace, 0, + convert_ARGB_to_A2RGB30_inplace, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB32 @@ -3123,9 +3136,9 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, convert_passthrough_inplace, convert_passthrough_inplace, - convert_RGB_to_RGB30_inplace, 0, - convert_RGB_to_RGB30_inplace, + 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -3150,10 +3163,10 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma mask_alpha_converter_rgbx_inplace, 0, 0, - convert_RGB_to_RGB30_inplace, 0, - convert_RGB_to_RGB30_inplace, + convert_ARGB_to_A2RGB30_inplace, 0, + convert_ARGB_to_A2RGB30_inplace, 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); -- cgit v1.2.3 From a866055d18b2c2efc0f3cf5307d8eac78cce26eb Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Wed, 6 Nov 2019 21:37:48 +0100 Subject: QHighDpiScaling: impove readability of screenSubfactor method Task-number: QTBUG-53022 Change-Id: Idae4379dd78d3125c375fad37a5a3af5bbcdc51e Reviewed-by: Friedemann Kleint --- src/gui/kernel/qhighdpiscaling.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 704dcee633..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,15 +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. - auto qScreen = screen->screen(); - auto byIndex = qScreen ? qScreen->property(scaleFactorProperty) : QVariant(); - 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; } } -- cgit v1.2.3 From 3e529369eb16704aa0d601a7f4b8e490dc8b772c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 7 Nov 2019 08:45:27 +0100 Subject: Support MaximizeUsingFullscreenGeometryHint in resizeMaximizedWindows() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In QPlatformScreen there is a convenience function which resizes windows when the screen changes. This did not have support for MaximizeUsingFullscreenGeometryHint and would mistakenly resize these windows to the available geometry. Since not all QPA plugins support this hint, we have to add a capability flag to avoid changing behavior on platforms where it works as intended. Task-number: QTBUG-74202 Change-Id: Ife88f597fbb3affa722f63ac18fb5719ffa8ed33 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformintegration.h | 3 ++- src/gui/kernel/qplatformscreen.cpp | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index d9f349555a..01406958e2 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -106,7 +106,8 @@ public: ApplicationIcon, SwitchableWidgetComposition, TopStackedNativeChildWindows, - OpenGLOnRasterSurface + OpenGLOnRasterSurface, + MaximizeUsingFullscreenGeometry }; virtual ~QPlatformIntegration() { } diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index f3213bf5ea..7daf48b191 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -410,15 +410,22 @@ void QPlatformScreen::resizeMaximizedWindows() const QRect newGeometry = deviceIndependentGeometry(); const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft()); + const bool supportsMaximizeUsingFullscreen = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MaximizeUsingFullscreenGeometry); + for (QWindow *w : windows()) { // Skip non-platform windows, e.g., offscreen windows. if (!w->handle()) continue; - if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) + if (supportsMaximizeUsingFullscreen + && w->windowState() & Qt::WindowMaximized + && w->flags() & Qt::MaximizeUsingFullscreenGeometryHint) { + w->setGeometry(newGeometry); + } else if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) { w->setGeometry(newAvailableGeometry); - else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) + } else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) { w->setGeometry(newGeometry); + } } } -- cgit v1.2.3 From f0a43a9def456784fd9408e3026d6689c8b715c1 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 7 Nov 2019 12:18:22 +0100 Subject: Make QPlatformPlaceholderScreen a sibling of other screens This is how the fake screen currently behaves in the xcb plugin. So if we are to deduplicate, it's probably best to match current behavior first. I still left an option for not being a virtual sibling in case other platforms don't support showing a window on a placeholder screen. Task-number: QTBUG-79711 Change-Id: I4e8b44d892efb85fdb003f1d473d0867442d7e4e Reviewed-by: Paul Olav Tvete --- src/gui/kernel/qplatformscreen.cpp | 14 ++++++++++++++ src/gui/kernel/qplatformscreen.h | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 7daf48b191..e511a6f5c4 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -616,4 +616,18 @@ int QPlatformScreen::preferredMode() const return 0; } +QList QPlatformPlaceholderScreen::virtualSiblings() const +{ + QList siblings; + + if (!m_virtualSibling) + return siblings; + + for (QScreen *screen : QGuiApplication::screens()) { + if (screen->handle() && screen->handle() != this) + siblings << screen->handle(); + } + return siblings; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index e27355a940..0be7646032 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -105,7 +105,7 @@ public: QPlatformScreen(); virtual ~QPlatformScreen(); - virtual bool isPlaceholder() const { return false; }; + virtual bool isPlaceholder() const { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; @@ -176,12 +176,23 @@ private: // Qt doesn't currently support running with no platform screen // QPA plugins can use this class to create a fake screen -class QPlatformPlaceholderScreen : public QPlatformScreen { - bool isPlaceholder() const override { return true; }; +class Q_GUI_EXPORT QPlatformPlaceholderScreen : public QPlatformScreen { +public: + // virtualSibling can be passed in to make the placeholder a sibling with other screens during + // the transitioning phase when the real screen is about to be removed, or the first real screen + // is about to be added. This is useful because Qt will currently recreate (but now show!) + // windows when they are moved from one virtual desktop to another, so if the last monitor is + // unplugged, then plugged in again, windows will be hidden unless the placeholder belongs to + // the same virtual desktop as the other screens. + QPlatformPlaceholderScreen(bool virtualSibling = true) : m_virtualSibling(virtualSibling) {} + bool isPlaceholder() const override { return true; } QRect geometry() const override { return QRect(); } QRect availableGeometry() const override { return QRect(); } int depth() const override { return 32; } QImage::Format format() const override { return QImage::Format::Format_RGB32; } + QList virtualSiblings() const override; +private: + bool m_virtualSibling = true; }; QT_END_NAMESPACE -- cgit v1.2.3 From 8f2db974ab594125301aac62594510e146125cb4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Nov 2019 11:15:32 +0100 Subject: Windows QPA: Fix wrong scaling of fixed size in window creation phase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a fixed size the window is moved to another screen by QPlatformWindow::initialGeometry(), the size constraints would be incorrectly scaled using the initial screen in the handling of WM_GETMINMAXINFO. To fix this, pass the resulting screen out of QPlatformWindow::initialGeometry() and use it during the window creation phase. Fixes: QTBUG-77307 Change-Id: I149a2a65e816da841a32abc14a495925bf9cc6f6 Reviewed-by: André de la Rocha Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qplatformwindow.cpp | 9 +++++++-- src/gui/kernel/qplatformwindow.h | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 2a0cb1094c..65accc9f68 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -694,9 +694,12 @@ static QSize fixInitialSize(QSize size, const QWindow *w, However if the given window already has geometry which the application has initialized, it takes priority. */ -QRect QPlatformWindow::initialGeometry(const QWindow *w, - const QRect &initialGeometry, int defaultWidth, int defaultHeight) +QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeometry, + int defaultWidth, int defaultHeight, + const QScreen **resultingScreenReturn) { + if (resultingScreenReturn) + *resultingScreenReturn = w->screen(); if (!w->isTopLevel()) { const qreal factor = QHighDpiScaling::factor(w); const QSize size = fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor), @@ -712,6 +715,8 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, : QGuiApplication::screenAt(initialGeometry.center()); if (!screen) return initialGeometry; + if (resultingScreenReturn) + *resultingScreenReturn = screen; // initialGeometry refers to window's screen QRect rect(QHighDpi::fromNativePixels(initialGeometry, w)); if (wp->resizeAutomatic) diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index 4d48cc2f13..b6aeb3a86a 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE class QPlatformScreen; class QPlatformWindowPrivate; +class QScreen; class QWindow; class QIcon; class QRegion; @@ -142,8 +143,9 @@ public: virtual void invalidateSurface(); - static QRect initialGeometry(const QWindow *w, - const QRect &initialGeometry, int defaultWidth, int defaultHeight); + static QRect initialGeometry(const QWindow *w, const QRect &initialGeometry, + int defaultWidth, int defaultHeight, + const QScreen **resultingScreenReturn = nullptr); virtual void requestUpdate(); bool hasPendingUpdateRequest() const; -- cgit v1.2.3 From 364160600889d6055a556a189e6f3d4a8dc3f96d Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 8 Nov 2019 14:02:01 +0100 Subject: Use default QTD font size for mono font when importing markdown QFontDatabase::systemFont(FixedFont) determines the font for inline code and code blocks in a markdown document. Now we change the size of that font to the same size as QTextDocument::defaultFont() so that the user has the ability to customize the font size in each document instead of only system-wide. Change-Id: Ief7367336f7613e88695dbb08bcb7e9f50db8961 Reviewed-by: Shawn Rutledge --- src/gui/text/qtextmarkdownimporter.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gui') diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index c2ad1e5612..78d18a714b 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -160,6 +160,10 @@ void QTextMarkdownImporter::import(QTextDocument *doc, const QString &markdown) m_paragraphMargin = m_doc->defaultFont().pointSize() * 2 / 3; m_cursor = new QTextCursor(doc); doc->clear(); + if (doc->defaultFont().pointSize() != -1) + m_monoFont.setPointSize(doc->defaultFont().pointSize()); + else + m_monoFont.setPixelSize(doc->defaultFont().pixelSize()); qCDebug(lcMD) << "default font" << doc->defaultFont() << "mono font" << m_monoFont; QByteArray md = markdown.toUtf8(); md_parse(md.constData(), MD_SIZE(md.size()), &callbacks, this); -- cgit v1.2.3 From 782df5b41dd3ab098fd1d3233339079487e1812f Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 11 Oct 2019 00:42:08 +0200 Subject: Make QObjectPrivate::threadData a proper atomic QObjectPrivate::threadData used to be a QThreadData *, and was read and written from multiple threads without proper synchronization. As an example, it was read from QCoreApplication::postEvent and written from QObject::moveToThread, therefore causing UB. Port threadData to a proper atomic, removing the races. Fix all usage points. In general, QObject is documented to be simply reentrant, not thread-safe, and certain bits (e.g. timers, moveToThread) are not even reentrant. The reasoning therefore is that a given QObject's threadData is not supposed to be touched by multiple threads without some synchronization happening elsewhere, and therefore relaxed loads should be sufficient. As drive-by change: refactor QCoreApplication::postEvent. It was particularly subtle, because it had a loop using a volatile to cope with the possibility of the receiver object switching thread while we tried to lock its thread's event queue. However, volatile does not achieve any synchronization, so drop it, and refactor the algorithm using better locking primitives. Put this algorithm in a common place, and also reuse it from removePostedEvents, which was lacking any synchronization. Change-Id: Icc755f7eb418ff54b33db4bdd87fd8eaf4e82c7a Reviewed-by: Thiago Macieira --- src/gui/kernel/qguiapplication_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 26f65b2f16..ee493faa5d 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -116,7 +116,7 @@ public: static QAbstractEventDispatcher *qt_qpa_core_dispatcher() { if (QCoreApplication::instance()) - return QCoreApplication::instance()->d_func()->threadData->eventDispatcher.loadRelaxed(); + return QCoreApplication::instance()->d_func()->threadData.loadRelaxed()->eventDispatcher.loadRelaxed(); else return nullptr; } -- cgit v1.2.3 From 1e5d1a43dc14240b24615d4cc9a291d5237ea8bf Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Nov 2019 13:02:32 +0100 Subject: Make sure the metatypes are installed in prefix builds The JSON collection step has to be target_predeps in order to be executed if the only place its output is referred to is INSTALLS. Furthermore, some CONFIG options clear the INSTALLS variable. Therefore, we need to add the metatypes CONFIG entries after those. Change-Id: I4694ab1d82c13cb4e3886c1722a03255d14b7f29 Reviewed-by: Simon Hausmann --- src/gui/gui.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/gui.pro b/src/gui/gui.pro index decfb364cf..350d4c5ee3 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -35,7 +35,7 @@ testcocoon { osx: LIBS_PRIVATE += -framework AppKit darwin: LIBS_PRIVATE += -framework CoreGraphics -CONFIG += simd optimize_full metatypes install_metatypes +CONFIG += simd optimize_full include(accessible/accessible.pri) include(kernel/kernel.pri) @@ -99,4 +99,4 @@ qtConfig(egl): CMAKE_EGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_EGL) QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist TRACEPOINT_PROVIDER = $$PWD/qtgui.tracepoints -CONFIG += qt_tracepoints +CONFIG += qt_tracepoints metatypes install_metatypes -- cgit v1.2.3 From a3f62d7ead78fde31bc26dd35d4bf6789a7b9e2f Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 9 Oct 2018 10:14:43 +1000 Subject: wasm: add platform qsettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the backend is async, the settings will not be ready to read/write instantly as on other platforms, but only be ready after the filesystem has been synced to the sandbox. This takes at least 250 to 500 ms. The QSettings status() or isWritable() can be used to discern when the settings are ready for use. This also fixes a crash in threaded wasm Task-number: QTBUG-70002 Fixes: QTBUG-63923 Fixes: QTBUG-79650 Change-Id: If24c6ada1b91b2a565ed6733da74972c3027f622 Reviewed-by: Edward Welbourne Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qguiapplication.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index f09f7e941b..455de52319 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1696,13 +1696,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() qt_gl_set_global_share_context(0); } #endif -#ifdef Q_OS_WASM - EM_ASM( - // unmount persistent directory as IDBFS - // see QTBUG-70002 - FS.unmount('/home/web_user'); - ); -#endif + platform_integration->destroy(); delete platform_theme; -- cgit v1.2.3 From 103d307f2e596e5e7d2eb706117223bf65264e5f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 30 Sep 2019 12:00:43 -0700 Subject: Be explicit about QDataStream serialization: explicit casts to int The reader uses int variables, so use the same in the writer. Change-Id: I1496b069cc534f1a838dfffd15c94c7cacd3dd93 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qshader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index c22b029dc8..9d35d83336 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -348,10 +348,10 @@ void QShader::removeShader(const QShaderKey &key) static void writeShaderKey(QDataStream *ds, const QShaderKey &k) { - *ds << k.source(); + *ds << int(k.source()); *ds << k.sourceVersion().version(); *ds << k.sourceVersion().flags(); - *ds << k.sourceVariant(); + *ds << int(k.sourceVariant()); } /*! @@ -369,7 +369,7 @@ QByteArray QShader::serialized() const return QByteArray(); ds << QSB_VERSION; - ds << d->stage; + ds << int(d->stage); ds << d->desc.toBinaryJson(); ds << d->shaders.count(); for (auto it = d->shaders.cbegin(), itEnd = d->shaders.cend(); it != itEnd; ++it) { -- cgit v1.2.3 From 80ac9e8b7ce8e3f79af0b00610a0a4b0ff17abe4 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 12 Nov 2019 17:59:51 +0100 Subject: Compile fix for MinGW 8.1.0 Workaround for libpng bug in GCC 8.1.0. Task-number: QTQAINFRA-3303 Change-Id: Id7668e795cb4ab16de3199fc3727d844aa31bfad Reviewed-by: Ville Voutilainen --- src/gui/image/image.pri | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gui') diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 3b2ced3f58..1f42f28d1e 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -79,6 +79,14 @@ qtConfig(png) { HEADERS += image/qpnghandler_p.h SOURCES += image/qpnghandler.cpp QMAKE_USE_PRIVATE += libpng + + win32:mingw { + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86048 + GCC_VERSION = "$${QMAKE_GCC_MAJOR_VERSION}.$${QMAKE_GCC_MINOR_VERSION}.$${QMAKE_GCC_PATCH_VERSION}" + equals(GCC_VERSION, "8.1.0") { + QMAKE_CXXFLAGS += -fno-reorder-blocks-and-partition + } + } } # SIMD -- cgit v1.2.3 From 01ec11507d7ef3de09bad9d1ef8e6d4a3d6c4428 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 10 Oct 2019 14:33:53 +0200 Subject: QStyleSheetStyle: add new property to QPushButton: icon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is currently no proper way to change the icon of a pushbutton from css. But there is a need for doing so (QTBUG-2982), and the typical work-around is to instead use the css property 'qproperty-icon'. But setting qproperties from the style is not a good idea in the first place, since it modifies the state of the widget it draws. Moreover, such properties are only set once (in QStyle::polish()), and will not have any effect on pseudo states, like hover. To close this gap, this patch will add a css property 'icon' that can be set on a QPushButton. This property will follow normal css cascading, and respect pseudo states, equal to any other css property. [ChangeLog][QtWidgets][QStyle] You can now set the CSS property 'icon' on a QPushButton to override which icon to draw. Fixes: QTBUG-79137 Change-Id: Ie7e0b0fa4f19471f51108cd4ca931356219d562e Reviewed-by: Christian Ehrlicher Reviewed-by: Jan Arve Sæther --- src/gui/text/qcssparser.cpp | 32 ++++++++++++++++++++++++++++++++ src/gui/text/qcssparser_p.h | 2 ++ 2 files changed, 34 insertions(+) (limited to 'src/gui') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index ce7c7610c1..793ef5774b 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -123,6 +123,7 @@ static const QCssKnownValue properties[NumProperties - 1] = { { "font-variant", FontVariant }, { "font-weight", FontWeight }, { "height", Height }, + { "icon", QtIcon }, { "image", QtImage }, { "image-position", QtImageAlignment }, { "left", Left }, @@ -1379,6 +1380,37 @@ bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size) return hit; } +bool ValueExtractor::extractIcon(QIcon *icon, QSize *size) +{ + // Find last declaration that specifies an icon + const auto declaration = std::find_if( + declarations.rbegin(), declarations.rend(), + [](const Declaration &decl) { return decl.d->propertyId == QtIcon; }); + if (declaration == declarations.rend()) + return false; + + *icon = declaration->iconValue(); + + // If the value contains a URI, try to get the size of the icon + if (declaration->d->values.isEmpty()) + return true; + + const auto &propertyValue = declaration->d->values.constFirst(); + if (propertyValue.type != Value::Uri) + return true; + + // First try to read just the size from the image without loading it + const QString url(propertyValue.variant.toString()); + QImageReader imageReader(url); + *size = imageReader.size(); + if (!size->isNull()) + return true; + + // Get the size by loading the image instead + *size = imageReader.read().size(); + return true; +} + /////////////////////////////////////////////////////////////////////////////// // Declaration QColor Declaration::colorValue(const QPalette &pal) const diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index ab85e76cf3..b8bf259dda 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -198,6 +198,7 @@ enum Property { QtLineHeightType, FontKerning, QtForegroundTextureCacheKey, + QtIcon, NumProperties }; @@ -855,6 +856,7 @@ struct Q_GUI_EXPORT ValueExtractor bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg); int extractStyleFeatures(); bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size); + bool extractIcon(QIcon *icon, QSize *size); int lengthValue(const Declaration &decl); -- cgit v1.2.3 From 54f5b8975055f1d48c74efab085acd6338aa1e3c Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 12 Nov 2019 10:46:00 +0100 Subject: Fix: QIcon high dpi scaling when aspect ratio differs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an icon engine is asked to produce a pixmap scaled to a certain size, it may return one with a different aspect ratio than requested. In particular, an SVG will use its own aspect ratio, as it should. QIcon's DPR calculation would break down in this case, resulting in ugly scaling. Fixes: QTBUG-79371 Change-Id: Id97049259dcee1a2980474250ef1163be5639085 Reviewed-by: Morten Johan Sørvig --- src/gui/image/qicon.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gui') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index df8220a0c6..0fe4cd45cb 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -165,6 +165,11 @@ QIconPrivate::QIconPrivate(QIconEngine *e) qreal QIconPrivate::pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const QSize &requestedSize, const QSize &actualSize) { QSize targetSize = requestedSize * displayDevicePixelRatio; + if ((actualSize.width() == targetSize.width() && actualSize.height() <= targetSize.height()) || + (actualSize.width() <= targetSize.width() && actualSize.height() == targetSize.height())) { + // Correctly scaled for dpr, just having different aspect ratio + return displayDevicePixelRatio; + } qreal scale = 0.5 * (qreal(actualSize.width()) / qreal(targetSize.width()) + qreal(actualSize.height() / qreal(targetSize.height()))); return qMax(qreal(1.0), displayDevicePixelRatio *scale); -- cgit v1.2.3 From 61def1f6cdf2eff521f77c9186fc3bb929359ab9 Mon Sep 17 00:00:00 2001 From: Florian Korsakissok Date: Wed, 13 Nov 2019 13:46:24 +0100 Subject: HiDPI: Select most fitting pixel ratio when painting QIcon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a way to select a better pixel ratio when the QPainter has a valid pointer to a QPaintDevice than simply getting the global app pixel ratio. Change-Id: I8f89fd01094bbac7a01a83be89991730b0fa6597 Reviewed-by: Thorbjørn Lund Martsum --- src/gui/image/qicon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 0fe4cd45cb..84e387e317 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -190,7 +190,12 @@ QPixmapIconEngine::~QPixmapIconEngine() void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { - QSize pixmapSize = rect.size() * qt_effective_device_pixel_ratio(0); + qreal dpr = 1.0; + if (QCoreApplication::testAttribute(Qt::AA_UseHighDpiPixmaps)) { + auto paintDevice = painter->device(); + dpr = paintDevice ? paintDevice->devicePixelRatioF() : qApp->devicePixelRatio(); + } + const QSize pixmapSize = rect.size() * dpr; QPixmap px = pixmap(pixmapSize, mode, state); painter->drawPixmap(rect, px); } -- cgit v1.2.3 From e19345987714f4f76c8d7075355980b154adbc44 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 18 Nov 2019 12:15:48 +0100 Subject: Fix kerning with fractional pixel size Since most of our APIs for pixel size are integer-based, we would assume it was when passing it to Harfbuzz. But QRawFont (and the internal APIs in Qt and Harfbuzz) support floating point pixel sizes. The result would be that setting e.g. pixel size 20.25 would give the same glyph positions as 20.75, but the glyphs would be some fraction of a pixel larger. Using floats instead should have no impact on the common case where the pixel size is an integer, but it should also enable the other case, where QRawFont is used (or potentially future APIs that do not have the integer limitation.) [ChangeLog][QtGui][Text] Fixed a problem where pixel sizes would be truncated before calculating glyph positions. Fixes: QTBUG-67091 Change-Id: Ib066b1330ddcf52d4b344412e350aa9a60c847ff Reviewed-by: Konstantin Ritt --- src/gui/text/qharfbuzzng.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index 9c8582b43d..397e6cc49f 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -695,12 +695,12 @@ _hb_qt_font_create(QFontEngine *fe) return NULL; } - const int y_ppem = fe->fontDef.pixelSize; - const int x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100; + const qreal y_ppem = fe->fontDef.pixelSize; + const qreal x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100.0; hb_font_set_funcs(font, hb_qt_get_font_funcs(), (void *)fe, NULL); - hb_font_set_scale(font, QFixed(x_ppem).value(), -QFixed(y_ppem).value()); - hb_font_set_ppem(font, x_ppem, y_ppem); + hb_font_set_scale(font, QFixed::fromReal(x_ppem).value(), -QFixed::fromReal(y_ppem).value()); + hb_font_set_ppem(font, int(x_ppem), int(y_ppem)); hb_font_set_ptem(font, fe->fontDef.pointSize); -- cgit v1.2.3 From ede867f581c0894e13d669f5364610df7ade0eb5 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 17 Nov 2019 13:10:41 +0100 Subject: QWheelEvent: add \since flag for ctor c08bf215cceda784cd02f8fa20e5b2431e0d9ef9 added a new QWheelEvent ctor but missed the \since flag. Fixes: QTBUG-80088 Change-Id: I6c81179999dd100162dc0cd5dc28e7b5b843b437 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 2b28052dd5..f555f4dc05 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -846,6 +846,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, /*! Constructs a wheel event object. + \since 5.12 The \a pos provides the location of the mouse cursor within the window. The position in global coordinates is specified by \a globalPos. -- cgit v1.2.3 From b10e1209e1c3655ee6e57185bb5375408ce02e56 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 4 Nov 2019 17:34:28 +0100 Subject: Implement inplace image conversion for generic down conversions If the destination image format is smaller than the source one, allow an inplace conversion followed by a shrinking realloc. Change-Id: I99b3e285e06fb37fd5fe7412749fa87f4cf2ee9a Reviewed-by: Eirik Aavitsland --- src/gui/image/qimage_conversions.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 4f3821a7cc..7cd71644a3 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -257,7 +257,8 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im // Cannot be used with indexed formats or between formats with different pixel depths. Q_ASSERT(dst_format > QImage::Format_Indexed8); Q_ASSERT(data->format > QImage::Format_Indexed8); - if (data->depth != qt_depthForFormat(dst_format)) + const int destDepth = qt_depthForFormat(dst_format); + if (data->depth < destDepth) return false; const QPixelLayout *srcLayout = &qPixelLayouts[data->format]; @@ -272,9 +273,16 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im uint buf[BufferSize]; uint *buffer = buf; uchar *srcData = data->data; + uchar *destData = data->data; - Q_ASSERT(srcLayout->bpp == destLayout->bpp); - Q_ASSERT(srcLayout->bpp != QPixelLayout::BPP64); + QImageData::ImageSizeParameters params = { data->bytes_per_line, data->nbytes }; + if (data->depth != destDepth) { + params = QImageData::calculateImageParameters(data->width, data->height, destDepth); + if (!params.isValid()) + return false; + } + + Q_ASSERT(destLayout->bpp != QPixelLayout::BPP64); FetchAndConvertPixelsFunc fetch = srcLayout->fetchToARGB32PM; ConvertAndStorePixelsFunc store = destLayout->storeFromARGB32PM; if (!srcLayout->hasAlphaChannel && destLayout->storeFromRGB32) { @@ -316,15 +324,26 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im while (x < data->width) { dither.x = x; int l = data->width - x; - if (destLayout->bpp == QPixelLayout::BPP32) + if (srcLayout->bpp == QPixelLayout::BPP32) buffer = reinterpret_cast(srcData) + x; else l = qMin(l, BufferSize); const uint *ptr = fetch(buffer, srcData, x, l, nullptr, ditherPtr); - store(srcData, ptr, x, l, nullptr, ditherPtr); + store(destData, ptr, x, l, nullptr, ditherPtr); x += l; } srcData += data->bytes_per_line; + destData += params.bytesPerLine; + } + if (params.totalSize != data->nbytes) { + Q_ASSERT(params.totalSize < data->nbytes); + void *newData = realloc(data->data, params.totalSize); + if (newData) { + data->data = (uchar *)newData; + data->nbytes = params.totalSize; + } + data->bytes_per_line = params.bytesPerLine; + data->depth = destDepth; } data->format = dst_format; return true; -- cgit v1.2.3 From 73a764c24700089228b4092e983061f788c6d232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 19 Nov 2019 17:15:50 +0100 Subject: =?UTF-8?q?Don=E2=80=99t=20warn=20on=20QT=5FAUTO=5FSCREEN=5FSCALE?= =?UTF-8?q?=5FFACTOR=20usage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This warning turned out to be spammy, since the env. variable may be set by KDE, in which case there is nothing the user or app developer can do to fix the situation. QT_AUTO_SCREEN_SCALE_FACTOR is now Done on X11, and remains Deprecated on all other platforms. Change-Id: I9d372655624b0e0b822f0a70e9aec4b18ab98630 Reviewed-by: Frederik Gladhorn --- src/gui/kernel/qhighdpiscaling.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 0782a49481..fde6bb0180 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -56,6 +56,9 @@ Q_LOGGING_CATEGORY(lcScaling, "qt.scaling"); #ifndef QT_NO_HIGHDPISCALING static const char legacyDevicePixelEnvVar[] = "QT_DEVICE_PIXEL_RATIO"; + +// Note: QT_AUTO_SCREEN_SCALE_FACTOR is Done on X11, and should be kept +// working as-is. It's Deprecated on all other platforms. static const char legacyAutoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR"; static const char enableHighDpiScalingEnvVar[] = "QT_ENABLE_HIGHDPI_SCALING"; @@ -104,12 +107,6 @@ static inline qreal initialGlobalScaleFactor() if (dpr > 0) result = dpr; } - - if (qEnvironmentVariableIsSet(legacyAutoScreenEnvVar)) { - qWarning("Warning: %s is deprecated. Instead use:\n" - " %s to enable platform plugin controlled per-screen factors.", - legacyAutoScreenEnvVar, enableHighDpiScalingEnvVar); - } } return result; } -- cgit v1.2.3 From af2daafde72db02454d24b7d691aa6861525ab99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 18 Nov 2019 17:01:26 +0100 Subject: Deprecate constructing QFlags from a pointer This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira --- src/gui/image/qimage.cpp | 6 +++--- src/gui/kernel/qplatformcursor.cpp | 2 +- src/gui/kernel/qplatformtheme.h | 2 +- src/gui/kernel/qsimpledrag.cpp | 2 +- src/gui/kernel/qsurfaceformat.cpp | 2 +- src/gui/opengl/qopenglbuffer.cpp | 4 ++-- src/gui/opengl/qopenglfunctions.cpp | 4 ++-- src/gui/opengl/qopenglpaintengine.cpp | 2 +- src/gui/painting/qpaintengineex.cpp | 2 +- src/gui/painting/qpainter.cpp | 16 ++++++++-------- src/gui/painting/qplatformbackingstore.cpp | 4 ++-- src/gui/painting/qplatformbackingstore.h | 2 +- src/gui/text/qcssparser.cpp | 2 +- src/gui/text/qdistancefield.cpp | 2 +- src/gui/text/qfontengine.cpp | 4 ++-- src/gui/text/qfontmetrics.cpp | 8 ++++---- src/gui/text/qglyphrun.cpp | 2 +- src/gui/text/qglyphrun_p.h | 3 +-- src/gui/text/qrawfont.cpp | 2 +- src/gui/text/qtextengine.cpp | 10 +++++----- src/gui/util/qgridlayoutengine.cpp | 2 +- src/gui/util/qgridlayoutengine_p.h | 4 ++-- src/gui/vulkan/qvulkanwindow_p.h | 2 +- 23 files changed, 44 insertions(+), 45 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d8ed0829af..869e206524 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1912,10 +1912,10 @@ void QImage::invertPixels(InvertMode mode) // Inverting premultiplied pixels would produce invalid image data. if (hasAlphaChannel() && qPixelLayouts[d->format].premultiplied) { if (depth() > 32) { - if (!d->convertInPlace(QImage::Format_RGBA64, 0)) + if (!d->convertInPlace(QImage::Format_RGBA64, { })) *this = convertToFormat(QImage::Format_RGBA64); } else { - if (!d->convertInPlace(QImage::Format_ARGB32, 0)) + if (!d->convertInPlace(QImage::Format_ARGB32, { })) *this = convertToFormat(QImage::Format_ARGB32); } } @@ -1982,7 +1982,7 @@ void QImage::invertPixels(InvertMode mode) } if (originalFormat != d->format) { - if (!d->convertInPlace(originalFormat, 0)) + if (!d->convertInPlace(originalFormat, { })) *this = convertToFormat(originalFormat); } } diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index 49eff2ad23..34c4549443 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE QPlatformCursor::clearOverrideCursor(). */ -QPlatformCursor::Capabilities QPlatformCursor::m_capabilities = 0; +QPlatformCursor::Capabilities QPlatformCursor::m_capabilities = { }; /*! \fn QPlatformCursor::QPlatformCursor() diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 356c4ea3ea..3185fc4541 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -309,7 +309,7 @@ public: virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; virtual QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = nullptr) const; + QPlatformTheme::IconOptions iconOptions = { }) const; virtual QIconEngine *createIconEngine(const QString &iconName) const; #ifndef QT_NO_SHORTCUT diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index d3070a3d1a..803206477c 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -393,7 +393,7 @@ void QSimpleDrag::startDrag() static void sendDragLeave(QWindow *window) { - QWindowSystemInterface::handleDrag(window, nullptr, QPoint(), Qt::IgnoreAction, 0, 0); + QWindowSystemInterface::handleDrag(window, nullptr, QPoint(), Qt::IgnoreAction, { }, { }); } void QSimpleDrag::cancel() diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 238886220b..571b820409 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class QSurfaceFormatPrivate { public: - explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = 0) + explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = { }) : ref(1) , opts(_opts) , redBufferSize(-1) diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp index 537097c09f..5ad16a8438 100644 --- a/src/gui/opengl/qopenglbuffer.cpp +++ b/src/gui/opengl/qopenglbuffer.cpp @@ -545,9 +545,9 @@ void *QOpenGLBuffer::map(QOpenGLBuffer::Access access) qWarning("QOpenGLBuffer::map(): buffer not created"); #endif if (!d->guard || !d->guard->id()) - return 0; + return nullptr; if (d->funcs->hasOpenGLExtension(QOpenGLExtensions::MapBufferRange)) { - QOpenGLBuffer::RangeAccessFlags rangeAccess = 0; + QOpenGLBuffer::RangeAccessFlags rangeAccess; switch (access) { case QOpenGLBuffer::ReadOnly: rangeAccess = QOpenGLBuffer::RangeRead; diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 8ec814296a..42186ace23 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -489,7 +489,7 @@ QOpenGLFunctions::OpenGLFeatures QOpenGLFunctions::openGLFeatures() const { QOpenGLFunctionsPrivateEx *d = static_cast(d_ptr); if (!d) - return 0; + return { }; if (d->m_features == -1) d->m_features = qt_gl_resolve_features(); return QOpenGLFunctions::OpenGLFeatures(d->m_features); @@ -527,7 +527,7 @@ QOpenGLExtensions::OpenGLExtensions QOpenGLExtensions::openGLExtensions() { QOpenGLFunctionsPrivateEx *d = static_cast(d_ptr); if (!d) - return 0; + return { }; if (d->m_extensions == -1) d->m_extensions = qt_gl_resolve_extensions(); return QOpenGLExtensions::OpenGLExtensions(d->m_extensions); diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 47394999c6..20cc2b5ae5 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1575,7 +1575,7 @@ void QOpenGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, c case QImage::Format_ARGB32: case QImage::Format_RGBA64: d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::NonPremultipliedImageSrc); - bindOption = 0; + bindOption = { }; break; case QImage::Format_Alpha8: if (ctx->functions()->hasOpenGLFeature(QOpenGLFunctions::TextureRGFormats)) { diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 8314e8bc8a..722afaf119 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -1061,7 +1061,7 @@ void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) QFontEngine *fontEngine = staticTextItem->fontEngine(); fontEngine->addGlyphsToPath(staticTextItem->glyphs, staticTextItem->glyphPositions, - staticTextItem->numGlyphs, &path, 0); + staticTextItem->numGlyphs, &path, { }); if (!path.isEmpty()) { QPainterState *s = state(); QPainter::RenderHints oldHints = s->renderHints; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3ce54c20be..4336ff66be 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5902,7 +5902,7 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif int numGlyphs = len; QVarLengthGlyphLayoutArray glyphs(len); QFontEngine *fontEngine = d->state->font.d->engineForScript(QChar::Script_Common); - if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) + if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, { })) Q_UNREACHABLE(); QTextItemInt gf(glyphs, &d->state->font, str.data(), len, fontEngine); @@ -6404,7 +6404,7 @@ Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t } QFixed width = rightMost - leftMost; - QTextItem::RenderFlags flags = 0; + QTextItem::RenderFlags flags; if (font.underline()) flags |= QTextItem::Underline; @@ -7213,7 +7213,7 @@ QPainter::RenderHints QPainter::renderHints() const Q_D(const QPainter); if (!d->engine) - return 0; + return { }; return d->state->renderHints; } @@ -7795,7 +7795,7 @@ QPainterState::QPainterState() composition_mode(QPainter::CompositionMode_SourceOver), emulationSpecifier(0), changeFlags(0) { - dirtyFlags = 0; + dirtyFlags = { }; } QPainterState::~QPainterState() @@ -7824,9 +7824,9 @@ void QPainterState::init(QPainter *p) { layoutDirection = QGuiApplication::layoutDirection(); composition_mode = QPainter::CompositionMode_SourceOver; emulationSpecifier = 0; - dirtyFlags = 0; + dirtyFlags = { }; changeFlags = 0; - renderHints = 0; + renderHints = { }; opacity = 1; } @@ -7883,7 +7883,7 @@ void QPainterState::init(QPainter *p) { /*! \fn void QPainter::drawImage(const QPointF &point, const QImage &image, const QRectF &source, - Qt::ImageConversionFlags flags = 0) + Qt::ImageConversionFlags flags = Qt::AutoColor) \overload @@ -7893,7 +7893,7 @@ void QPainterState::init(QPainter *p) { /*! \fn void QPainter::drawImage(const QPoint &point, const QImage &image, const QRect &source, - Qt::ImageConversionFlags flags = 0) + Qt::ImageConversionFlags flags = Qt::AutoColor) \overload Draws the rectangular portion \a source of the given \a image with diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 45e90bd99b..0ecb4390e9 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -427,7 +427,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i origin = QOpenGLTextureBlitter::OriginBottomLeft; textureId = d_ptr->textureId; } else { - TextureFlags flags = 0; + TextureFlags flags; textureId = toTexture(deviceRegion(region, window, offset), &d_ptr->textureSize, &flags); d_ptr->needsSwizzle = (flags & TextureSwizzle) != 0; d_ptr->premultiplied = (flags & TexturePremultiplied) != 0; @@ -534,7 +534,7 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu GLuint pixelType = GL_UNSIGNED_BYTE; bool needsConversion = false; - *flags = 0; + *flags = { }; switch (image.format()) { case QImage::Format_ARGB32_Premultiplied: *flags |= TexturePremultiplied; diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h index 4f08b0092f..7aa054f1e2 100644 --- a/src/gui/painting/qplatformbackingstore.h +++ b/src/gui/painting/qplatformbackingstore.h @@ -100,7 +100,7 @@ public: bool isLocked() const; void appendTexture(void *source, GLuint textureId, const QRect &geometry, - const QRect &clipRect = QRect(), Flags flags = nullptr); + const QRect &clipRect = QRect(), Flags flags = { }); void clear(); Q_SIGNALS: diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 793ef5774b..cf3d8e5ea2 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -682,7 +682,7 @@ bool ValueExtractor::extractOutline(int *borders, QBrush *colors, BorderStyle *s static Qt::Alignment parseAlignment(const QCss::Value *values, int count) { - Qt::Alignment a[2] = { 0, 0 }; + Qt::Alignment a[2] = { { }, { } }; for (int i = 0; i < qMin(2, count); i++) { if (values[i].type != Value::KnownIdentifier) break; diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index d8a971c7b7..89f943ca51 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -952,7 +952,7 @@ void QDistanceField::setGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubl { QFixedPoint position; QPainterPath path; - fontEngine->addGlyphsToPath(&glyph, &position, 1, &path, 0); + fontEngine->addGlyphsToPath(&glyph, &position, 1, &path, { }); path.translate(-path.boundingRect().topLeft()); path.setFillRule(Qt::WindingFill); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 403a0510fa..3a1f5ed4f4 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -506,7 +506,7 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform g.numGlyphs = 1; g.glyphs = &kashidaGlyph; g.advances = &kashidaWidth; - recalcAdvances(&g, 0); + recalcAdvances(&g, { }); for (uint k = 0; k < glyphs.justifications[i].nKashidas; ++k) { xpos -= kashidaWidth; @@ -948,7 +948,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph) im.fill(Qt::transparent); QPainter p(&im); p.setRenderHint(QPainter::Antialiasing); - addGlyphsToPath(&glyph, &pt, 1, &path, 0); + addGlyphsToPath(&glyph, &pt, 1, &path, { }); p.setPen(Qt::NoPen); p.setBrush(Qt::black); p.drawPath(path); diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index d3e4f11e8c..906047cdb4 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -562,7 +562,7 @@ int QFontMetrics::width(const QString &text, int len, int flags) const int numGlyphs = len; QVarLengthGlyphLayoutArray glyphs(numGlyphs); QFontEngine *engine = d->engineForScript(QChar::Script_Common); - if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, 0)) + if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, { })) Q_UNREACHABLE(); QFixed width; @@ -684,7 +684,7 @@ int QFontMetrics::horizontalAdvance(QChar ch) const glyphs.numGlyphs = 1; glyphs.glyphs = &glyph; glyphs.advances = &advance; - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); return qRound(advance); } @@ -736,7 +736,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const glyphs.numGlyphs = 1; glyphs.glyphs = &glyph; glyphs.advances = &advance; - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); width = qRound(advance); } @@ -1619,7 +1619,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const glyphs.numGlyphs = 1; glyphs.glyphs = &glyph; glyphs.advances = &advance; - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); return advance.toReal(); } diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp index 3c16c3bf62..f4cd839f15 100644 --- a/src/gui/text/qglyphrun.cpp +++ b/src/gui/text/qglyphrun.cpp @@ -279,7 +279,7 @@ void QGlyphRun::clear() { detach(); d->rawFont = QRawFont(); - d->flags = 0; + d->flags = { }; setPositions(QVector()); setGlyphIndexes(QVector()); diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h index 465c3c7000..46e2a8bbfb 100644 --- a/src/gui/text/qglyphrun_p.h +++ b/src/gui/text/qglyphrun_p.h @@ -65,8 +65,7 @@ class QGlyphRunPrivate: public QSharedData { public: QGlyphRunPrivate() - : flags(nullptr) - , glyphIndexData(glyphIndexes.constData()) + : glyphIndexData(glyphIndexes.constData()) , glyphIndexDataSize(0) , glyphPositionData(glyphPositions.constData()) , glyphPositionDataSize(0) diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index a060448924..e04c8909f3 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -303,7 +303,7 @@ QPainterPath QRawFont::pathForGlyph(quint32 glyphIndex) const QFixedPoint position; QPainterPath path; - d->fontEngine->addGlyphsToPath(&glyphIndex, &position, 1, &path, 0); + d->fontEngine->addGlyphsToPath(&glyphIndex, &position, 1, &path, { }); return path; } diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 209433dac5..40adc4a3cf 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1720,7 +1720,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, g.glyphs[i] = actualFontEngine->glyphIndex('-'); if (Q_LIKELY(g.glyphs[i] != 0)) { QGlyphLayout tmp = g.mid(i, 1); - actualFontEngine->recalcAdvances(&tmp, 0); + actualFontEngine->recalcAdvances(&tmp, { }); } g.attributes[i].dontPrint = true; } @@ -2581,7 +2581,7 @@ static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph, g.numGlyphs = 1; g.glyphs = &kashidaGlyph; g.advances = &point->kashidaWidth; - fe->recalcAdvances(&g, 0); + fe->recalcAdvances(&g, { }); if (point->kashidaWidth == 0) point->type = Justification_Prohibited; @@ -3214,13 +3214,13 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int glyphs.advances = &ellipsisWidth; if (glyph != 0) { - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); ellipsisText = ellipsisChar; } else { glyph = engine->glyphIndex('.'); if (glyph != 0) { - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); ellipsisWidth *= 3; ellipsisText = QStringLiteral("..."); @@ -3928,7 +3928,7 @@ void QTextItemInt::initWithScriptItem(const QScriptItem &si) { // explicitly initialize flags so that initFontAttributes can be called // multiple times on the same TextItem - flags = 0; + flags = { }; if (si.analysis.bidiLevel %2) flags |= QTextItem::RightToLeft; ascent = si.ascent; diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 33adac40b2..024f0f084e 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -1147,7 +1147,7 @@ QLayoutPolicy::ControlTypes QGridLayoutEngine::controlTypes(LayoutSide side) con Qt::Orientation orientation = (side == Top || side == Bottom) ? Qt::Vertical : Qt::Horizontal; int row = (side == Top || side == Left) ? effectiveFirstRow(orientation) : effectiveLastRow(orientation); - QLayoutPolicy::ControlTypes result = 0; + QLayoutPolicy::ControlTypes result; for (int column = columnCount(orientation) - 1; column >= 0; --column) { if (QGridLayoutItem *item = itemAt(row, column, orientation)) diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h index 5f0e84edb1..181326103b 100644 --- a/src/gui/util/qgridlayoutengine_p.h +++ b/src/gui/util/qgridlayoutengine_p.h @@ -276,7 +276,7 @@ class Q_GUI_EXPORT QGridLayoutItem { public: QGridLayoutItem(int row, int column, int rowSpan = 1, int columnSpan = 1, - Qt::Alignment alignment = nullptr); + Qt::Alignment alignment = { }); virtual ~QGridLayoutItem() {} inline int firstRow() const { return q_firstRows[Ver]; } @@ -339,7 +339,7 @@ private: class Q_GUI_EXPORT QGridLayoutEngine { public: - QGridLayoutEngine(Qt::Alignment defaultAlignment = Qt::Alignment(nullptr), bool snapToPixelGrid = false); + QGridLayoutEngine(Qt::Alignment defaultAlignment = { }, bool snapToPixelGrid = false); inline ~QGridLayoutEngine() { qDeleteAll(q_items); } int rowCount(Qt::Orientation orientation) const; diff --git a/src/gui/vulkan/qvulkanwindow_p.h b/src/gui/vulkan/qvulkanwindow_p.h index 777be237a8..915e359673 100644 --- a/src/gui/vulkan/qvulkanwindow_p.h +++ b/src/gui/vulkan/qvulkanwindow_p.h @@ -97,7 +97,7 @@ public: int physDevIndex = 0; QVector physDevs; QVector physDevProps; - QVulkanWindow::Flags flags = nullptr; + QVulkanWindow::Flags flags; QByteArrayList requestedDevExtensions; QHash > supportedDevExtensions; QVector requestedColorFormats; -- cgit v1.2.3 From 5142fe2c54970040fb6967848156a5f28b5a2dc9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 16 Nov 2019 19:25:11 +0100 Subject: rhi: d3d11: Do not rely on Win10-only enum value When building against a 8.1 or older SDK the Windows 10-only value DXGI_SWAP_EFFECT_FLIP_DISCARD may not be present. Just use the value directly. At runtime that code path cannot be hit anyway when running on 8.1 or older. Task-number: QTBUG-80084 Change-Id: I0974b82db770e5487315798432ee601937b96c5e Reviewed-by: Friedemann Kleint --- src/gui/rhi/qrhid3d11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 717f3e6d6c..5e576e9c6a 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -3922,7 +3922,7 @@ bool QD3D11SwapChain::buildOrResize() desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; desc.BufferCount = BUFFER_COUNT; desc.Scaling = DXGI_SCALING_STRETCH; - desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; + desc.SwapEffect = DXGI_SWAP_EFFECT(4); // DXGI_SWAP_EFFECT_FLIP_DISCARD // Do not bother with AlphaMode, if won't work unless we go through // DirectComposition. Instead, we just take the other (DISCARD) // path for now when alpha is requested. -- cgit v1.2.3 From 2c871dfd38d89d6415c2c25d47b4a0e9c8b2ef11 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Nov 2019 15:34:38 +0100 Subject: Avoid initializing QFlags with 0 or nullptr in further cases Amends qtbase/af2daafde72db02454d24b7d691aa6861525ab99. Where applicable, port over to member initialization, thus also fixing nullptr warnings. Change-Id: Iaaf2dbbbcf2952253390b8839fd15a1b17be32c0 Reviewed-by: Allan Sandfeld Jensen --- src/gui/kernel/qguiapplication.cpp | 2 +- src/gui/kernel/qplatformdialoghelper.cpp | 22 +++++++--------------- src/gui/painting/qpainter.cpp | 11 ++--------- src/gui/painting/qpainter_p.h | 20 ++++++++++---------- src/gui/painting/qpainterpath.cpp | 2 +- src/gui/text/qfontengine.cpp | 2 +- src/gui/text/qtextengine.cpp | 15 +++------------ src/gui/text/qtextengine_p.h | 19 ++++++++----------- src/gui/vulkan/qvulkaninstance.cpp | 1 - 9 files changed, 33 insertions(+), 61 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 455de52319..ef31e475ea 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1763,7 +1763,7 @@ Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() */ Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() { - CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers(0)) + CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers{}) QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); return pi->queryKeyboardModifiers(); } diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index 4bee153489..15ac4acf91 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -186,7 +186,7 @@ QVariant QPlatformDialogHelper::defaultStyleHint(QPlatformDialogHelper::StyleHi class QFontDialogOptionsPrivate : public QSharedData { public: - QFontDialogOptionsPrivate() : options(0) {} + QFontDialogOptionsPrivate() = default; QFontDialogOptions::FontDialogOptions options; QString windowTitle; @@ -328,7 +328,7 @@ Q_GLOBAL_STATIC(QColorDialogStaticData, qColorDialogStaticData) class QColorDialogOptionsPrivate : public QSharedData { public: - QColorDialogOptionsPrivate() : options(0) {} + QColorDialogOptionsPrivate() = default; // Write out settings around destruction of dialogs ~QColorDialogOptionsPrivate() { qColorDialogStaticData()->writeSettings(); } @@ -465,24 +465,16 @@ void QPlatformColorDialogHelper::setOptions(const QSharedPointer sidebarUrls; - bool useDefaultNameFilters; + bool useDefaultNameFilters = true; QStringList nameFilters; QStringList mimeTypeFilters; QString defaultSuffix; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 4336ff66be..d5cec1b45a 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7786,16 +7786,9 @@ QPainterState::QPainterState(const QPainterState *s) } QPainterState::QPainterState() - : brushOrigin(0, 0), bgBrush(Qt::white), clipOperation(Qt::NoClip), - renderHints(0), - wx(0), wy(0), ww(0), wh(0), vx(0), vy(0), vw(0), vh(0), - opacity(1), WxF(false), VxF(false), clipEnabled(true), - bgMode(Qt::TransparentMode), painter(0), - layoutDirection(QGuiApplication::layoutDirection()), - composition_mode(QPainter::CompositionMode_SourceOver), - emulationSpecifier(0), changeFlags(0) + : brushOrigin(0, 0), WxF(false), VxF(false), clipEnabled(true), + layoutDirection(QGuiApplication::layoutDirection()) { - dirtyFlags = { }; } QPainterState::~QPainterState() diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 29d4880eb9..285bd90502 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -154,29 +154,29 @@ public: QFont deviceFont; QPen pen; QBrush brush; - QBrush bgBrush; // background brush + QBrush bgBrush = Qt::white; // background brush QRegion clipRegion; QPainterPath clipPath; - Qt::ClipOperation clipOperation; + Qt::ClipOperation clipOperation = Qt::NoClip; QPainter::RenderHints renderHints; QVector clipInfo; // ### Make me smaller and faster to copy around... QTransform worldMatrix; // World transformation matrix, not window and viewport QTransform matrix; // Complete transformation matrix, QTransform redirectionMatrix; - int wx, wy, ww, wh; // window rectangle - int vx, vy, vw, vh; // viewport rectangle - qreal opacity; + int wx = 0, wy = 0, ww = 0, wh = 0; // window rectangle + int vx = 0, vy = 0, vw = 0, vh = 0; // viewport rectangle + qreal opacity = 1; uint WxF:1; // World transformation uint VxF:1; // View transformation uint clipEnabled:1; - Qt::BGMode bgMode; - QPainter *painter; + Qt::BGMode bgMode = Qt::TransparentMode; + QPainter *painter = nullptr; Qt::LayoutDirection layoutDirection; - QPainter::CompositionMode composition_mode; - uint emulationSpecifier; - uint changeFlags; + QPainter::CompositionMode composition_mode = QPainter::CompositionMode_SourceOver; + uint emulationSpecifier = 0; + uint changeFlags = 0; }; struct QPainterDummyState diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 1fb37ece56..859122c3b9 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString & fe->addOutlineToPath(x, y, glyphs, this, si.analysis.bidiLevel % 2 ? QTextItem::RenderFlags(QTextItem::RightToLeft) - : QTextItem::RenderFlags(0)); + : QTextItem::RenderFlags{}); const qreal lw = fe->lineThickness().toReal(); if (f.d->underline) { diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 3a1f5ed4f4..1668fac5a3 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -141,7 +141,7 @@ static void hb_getAdvances(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGl qglyphs.glyphs = const_cast(glyphs); qglyphs.advances = reinterpret_cast(advances); - fe->recalcAdvances(&qglyphs, (flags & HB_ShaperFlag_UseDesignMetrics) ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0)); + fe->recalcAdvances(&qglyphs, (flags & HB_ShaperFlag_UseDesignMetrics) ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags{}); } static HB_Bool hb_canRender(HB_Font font, const HB_UChar16 *string, hb_uint32 length) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 40adc4a3cf..8a91b34b7a 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1896,7 +1896,7 @@ int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *stri } if (kerningEnabled && !shaper_item.kerning_applied) - actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0)); + actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags{}); if (engineIdx != 0) { for (quint32 i = 0; i < shaper_item.num_glyphs; ++i) @@ -3895,12 +3895,7 @@ QStackTextEngine::QStackTextEngine(const QString &string, const QFont &f) } QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format) - : justified(false), - underlineStyle(QTextCharFormat::NoUnderline), - charFormat(format), - num_chars(0), - chars(nullptr), - logClusters(nullptr), + : charFormat(format), f(font), fontEngine(font->d->engineForScript(si.analysis.script)) { @@ -3910,13 +3905,9 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo } QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format) - : flags(0), - justified(false), - underlineStyle(QTextCharFormat::NoUnderline), - charFormat(format), + : charFormat(format), num_chars(numChars), chars(chars_), - logClusters(nullptr), f(font), glyphs(g), fontEngine(fe) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 76b9757eba..f069951ce5 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -303,10 +303,7 @@ struct QScriptItem; class QTextItemInt : public QTextItem { public: - inline QTextItemInt() - : justified(false), underlineStyle(QTextCharFormat::NoUnderline), num_chars(0), chars(nullptr), - logClusters(nullptr), f(nullptr), fontEngine(nullptr) - {} + inline QTextItemInt() = default; QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format = QTextCharFormat()); QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe, const QTextCharFormat &format = QTextCharFormat()); @@ -321,16 +318,16 @@ public: QFixed width; RenderFlags flags; - bool justified; - QTextCharFormat::UnderlineStyle underlineStyle; + bool justified = false; + QTextCharFormat::UnderlineStyle underlineStyle = QTextCharFormat::NoUnderline; const QTextCharFormat charFormat; - int num_chars; - const QChar *chars; - const unsigned short *logClusters; - const QFont *f; + int num_chars = 0; + const QChar *chars = nullptr; + const unsigned short *logClusters = nullptr; + const QFont *f = nullptr; QGlyphLayout glyphs; - QFontEngine *fontEngine; + QFontEngine *fontEngine = nullptr; }; struct QScriptItem diff --git a/src/gui/vulkan/qvulkaninstance.cpp b/src/gui/vulkan/qvulkaninstance.cpp index daf37e3dc8..764cb917ad 100644 --- a/src/gui/vulkan/qvulkaninstance.cpp +++ b/src/gui/vulkan/qvulkaninstance.cpp @@ -251,7 +251,6 @@ public: QVulkanInstancePrivate(QVulkanInstance *q) : q_ptr(q), vkInst(VK_NULL_HANDLE), - flags(0), errorCode(VK_SUCCESS) { } ~QVulkanInstancePrivate() { reset(); } -- cgit v1.2.3 From 03b1d2c44940322208c12c7bceee376b51d8e852 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 30 Jun 2018 21:23:02 +0200 Subject: QColor: unify behavior when passing invalid values to setFoo() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling QColor::setFoo() is currently inconsistent - some setter do invalidate the colors, some don't. Unify it by calling invalidate in every setter. Task-number: QTBUG-62452 Change-Id: Ia4f0bd16ea30e9659bc989ffc2b319892438b84b Reviewed-by: André Hartmann Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qcolor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 8780cce223..23afba6cce 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -1086,6 +1086,7 @@ void QColor::setHsvF(qreal h, qreal s, qreal v, qreal a) || (v < qreal(0.0) || v > qreal(1.0)) || (a < qreal(0.0) || a > qreal(1.0))) { qWarning("QColor::setHsvF: HSV parameters out of range"); + invalidate(); return; } @@ -1198,7 +1199,8 @@ void QColor::setHslF(qreal h, qreal s, qreal l, qreal a) || (s < qreal(0.0) || s > qreal(1.0)) || (l < qreal(0.0) || l > qreal(1.0)) || (a < qreal(0.0) || a > qreal(1.0))) { - qWarning("QColor::setHsvF: HSV parameters out of range"); + qWarning("QColor::setHslF: HSL parameters out of range"); + invalidate(); return; } @@ -1224,7 +1226,7 @@ void QColor::setHslF(qreal h, qreal s, qreal l, qreal a) void QColor::setHsl(int h, int s, int l, int a) { if (h < -1 || (uint)s > 255 || (uint)l > 255 || (uint)a > 255) { - qWarning("QColor::setHsv: HSV parameters out of range"); + qWarning("QColor::setHsl: HSL parameters out of range"); invalidate(); return; } @@ -2719,6 +2721,7 @@ void QColor::setCmyk(int c, int m, int y, int k, int a) || k < 0 || k > 255 || a < 0 || a > 255) { qWarning("QColor::setCmyk: CMYK parameters out of range"); + invalidate(); return; } @@ -2748,6 +2751,7 @@ void QColor::setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a) || k < qreal(0.0) || k > qreal(1.0) || a < qreal(0.0) || a > qreal(1.0)) { qWarning("QColor::setCmykF: CMYK parameters out of range"); + invalidate(); return; } -- cgit v1.2.3 From 0e0793ca590439bd437310f1e80507d21be3f14d Mon Sep 17 00:00:00 2001 From: Langonda Agag Date: Mon, 25 Nov 2019 07:25:46 +0000 Subject: Improve QTextDocumentPrivate cursor performance The cursors in QTextDocumentPrivate are held in a QList. This becomes a serious performance problem with lots of extra selections due to a call to QTextDocumentPrivate::removeCursor() from the QTextCursor destructor. Given the following test program: QPlainTextEdit *editor = ... std::list< QTextCursor> list; for(int i = 0; i < 100000; ++i) { QTextCursor c(editor->document()); c.setPosition(std::rand()%100); list.push_front(c); } list.clear(); // <-- clear calls hangs for 3+ seconds // due to time spent in // QTextDocumentPrivate::removeCursor() // due to QList::removeAll() call Note the push_front because it exacerbates the issue because the entire list will be traversed. The change submitted changes the structure to a set, removing the issue. In theory, this limits that a cursors cannot be in the structure twice, but this neither happens nor would it make sense. Change-Id: I817dc5d1bda1d98c6725a531b32d1c711a029a34 Reviewed-by: Langonda Agag Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Jesus Fernandez --- src/gui/text/qtextdocument_p.cpp | 2 +- src/gui/text/qtextdocument_p.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index a1b1c2e92b..2f02f62a57 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -243,7 +243,7 @@ void QTextDocumentPrivate::clear() curs->adjusted_anchor = 0; } - QListoldCursors = cursors; + QSet oldCursors = cursors; QT_TRY{ cursors.clear(); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index f4e7a25f22..94c67b3264 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -277,8 +277,8 @@ private: public: void documentChange(int from, int length); - inline void addCursor(QTextCursorPrivate *c) { cursors.append(c); } - inline void removeCursor(QTextCursorPrivate *c) { cursors.removeAll(c); } + inline void addCursor(QTextCursorPrivate *c) { cursors.insert(c); } + inline void removeCursor(QTextCursorPrivate *c) { cursors.remove(c); } QTextFrame *frameAt(int pos) const; QTextFrame *rootFrame() const; @@ -330,7 +330,7 @@ private: BlockMap blocks; int initialBlockCharFormatIndex; - QList cursors; + QSet cursors; QMap objects; QMap resources; QMap cachedResources; -- cgit v1.2.3 From 108e73602d60904b204cc71e9daaee084c66ce7b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 19 Nov 2019 15:43:38 +0100 Subject: Fix Qt6 TODOs in qcolor Do trivial binary but source compatible changes. Change-Id: Ifd2c3dea1dda80a46594ad413425d7800cc74dd8 Reviewed-by: Christian Ehrlicher --- src/gui/painting/qcolor.cpp | 44 -------------------------------------------- src/gui/painting/qcolor.h | 17 +---------------- 2 files changed, 1 insertion(+), 60 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 23afba6cce..c567b25468 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -854,18 +854,6 @@ QColor::QColor(Spec spec) noexcept Returns \c true if the color is valid; otherwise returns \c false. */ -/*! - Returns the name of the color in the format "#RRGGBB"; i.e. a "#" - character followed by three two-digit hexadecimal numbers. - - \sa setNamedColor() -*/ - -QString QColor::name() const -{ - return name(HexRgb); -} - /*! \since 5.2 @@ -2627,16 +2615,6 @@ QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a) return color; } -/*! - \obsolete - - Use the \c const overload instead. -*/ -void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) -{ - const_cast(this)->getCmyk(c, m, y, k, a); -} - /*! Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components @@ -2666,16 +2644,6 @@ void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) const *a = ct.acmyk.alpha >> 8; } -/*! - \obsolete - - Use the \c const overload instead. -*/ -void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a) -{ - const_cast(this)->getCmykF(c, m, y, k, a); -} - /*! Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components @@ -2924,18 +2892,6 @@ QColor QColor::dark(int factor) const noexcept } #endif -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -/*! - Assigns a copy of \a color to this color, and returns a reference to it. -*/ -QColor &QColor::operator=(const QColor &color) noexcept -{ - cspec = color.cspec; - ct.argb = color.ct.argb; - return *this; -} -#endif - /*! \overload Assigns a copy of \a color and returns a reference to this color. */ diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index c3111f9e3b..423a0ac50f 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -89,24 +89,11 @@ public: inline QColor(QLatin1String name); QColor(Spec spec) noexcept; -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) - // ### Qt 6: remove all of these, the trivial ones are fine. - Q_DECL_CONSTEXPR QColor(const QColor &color) noexcept - : cspec(color.cspec), ct(color.ct) - {} - Q_DECL_CONSTEXPR QColor(QColor &&other) noexcept : cspec(other.cspec), ct(other.ct) {} - QColor &operator=(QColor &&other) noexcept - { cspec = other.cspec; ct = other.ct; return *this; } - QColor &operator=(const QColor &) noexcept; -#endif // Qt < 6 - QColor &operator=(Qt::GlobalColor color) noexcept; bool isValid() const noexcept; - // ### Qt 6: merge overloads - QString name() const; - QString name(NameFormat format) const; + QString name(NameFormat format = HexRgb) const; #if QT_STRINGVIEW_LEVEL < 2 void setNamedColor(const QString& name); @@ -182,11 +169,9 @@ public: qreal yellowF() const noexcept; qreal blackF() const noexcept; - void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr); // ### Qt 6: remove void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr) const; void setCmyk(int c, int m, int y, int k, int a = 255); - void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr); // ### Qt 6: remove void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr) const; void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a = 1.0); -- cgit v1.2.3 From 8a60244da8f34aaa4ba0f71ada5b87aee33e0715 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Sun, 24 Nov 2019 21:45:46 +0100 Subject: Fix renderbufferStorageMultisample: invalid internalformat Chrome 78 is outputting "INVALID_ENUM: renderbufferStorageMultisample: invalid internalformat" when running a Qt application after building it for WebAssembly (WASM) against the Qt 5.13 branch using the Emscripten 1.39.3 (upstream) compiler. The problem appear to be caused by glRenderbufferStorageMultisample not supporting GL_DEPTH_STENCIL directly. Instead, GL_DEPTH24_STENCIL8 or GL_DEPTH32F_STENCIL8 should be passed. Keeping the glRenderbufferStorage call as-is. Change-Id: I777dbc26b1d989950525a434a25ed344389f5059 Reference: https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glRenderbufferStorageMultisample.xhtml Fixes: QTBUG-80286 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglframebufferobject.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 5d30891565..bb0dbdc9bd 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -658,13 +658,11 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer)); - GLenum storageFormat = GL_DEPTH_STENCIL; - if (samples != 0 ) { funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - storageFormat, dsSize.width(), dsSize.height()); + GL_DEPTH24_STENCIL8, dsSize.width(), dsSize.height()); } else { - funcs.glRenderbufferStorage(GL_RENDERBUFFER, storageFormat, + funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, dsSize.width(), dsSize.height()); } -- cgit v1.2.3 From f3c37c839c5350c9d9c14074ea1cccd881281850 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 12 Nov 2019 17:13:58 +0100 Subject: Enable QRhi Metal backend on iOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While we are at it, remove the Border and MirrorOnce wrap modes that have not been supported on OpenGL, because they are unsupported with Metal+iOS as well. Task-number: QTBUG-78580 Change-Id: I0db94b9d3a6125b3bb5d7b1db5d02a42cd94d2c2 Reviewed-by: Tor Arne Vestbø --- src/gui/rhi/qrhi.cpp | 8 ++---- src/gui/rhi/qrhi_p.h | 2 -- src/gui/rhi/qrhid3d11.cpp | 4 --- src/gui/rhi/qrhigles2.cpp | 5 ---- src/gui/rhi/qrhimetal.mm | 64 ++++++++++++++++++++++++++++++++++++++-------- src/gui/rhi/qrhivulkan.cpp | 4 --- src/gui/rhi/rhi.pri | 6 ++--- 7 files changed, 59 insertions(+), 34 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 8ef98d2e42..ac5836fc68 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -48,8 +48,7 @@ #ifdef Q_OS_WIN #include "qrhid3d11_p_p.h" #endif -//#ifdef Q_OS_DARWIN -#ifdef Q_OS_MACOS +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) #include "qrhimetal_p_p.h" #endif @@ -2253,9 +2252,7 @@ bool QRhiTexture::buildFrom(const QRhiNativeHandles *src) \value Repeat \value ClampToEdge - \value Border \value Mirror - \value MirrorOnce */ /*! @@ -4049,8 +4046,7 @@ QRhi *QRhi::create(Implementation impl, QRhiInitParams *params, Flags flags, QRh break; #endif case Metal: -//#ifdef Q_OS_DARWIN -#ifdef Q_OS_MACOS +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) r->d = new QRhiMetal(static_cast(params), static_cast(importDevice)); break; diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 907924c788..8cc4c7a06c 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -812,9 +812,7 @@ public: enum AddressMode { Repeat, ClampToEdge, - Border, Mirror, - MirrorOnce }; enum CompareOp { diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 5e576e9c6a..7e05aefe8d 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -2862,12 +2862,8 @@ static inline D3D11_TEXTURE_ADDRESS_MODE toD3DAddressMode(QRhiSampler::AddressMo return D3D11_TEXTURE_ADDRESS_WRAP; case QRhiSampler::ClampToEdge: return D3D11_TEXTURE_ADDRESS_CLAMP; - case QRhiSampler::Border: - return D3D11_TEXTURE_ADDRESS_BORDER; case QRhiSampler::Mirror: return D3D11_TEXTURE_ADDRESS_MIRROR; - case QRhiSampler::MirrorOnce: - return D3D11_TEXTURE_ADDRESS_MIRROR_ONCE; default: Q_UNREACHABLE(); return D3D11_TEXTURE_ADDRESS_CLAMP; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index abee843a74..ab61050e3e 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -1785,11 +1785,6 @@ static inline GLenum toGlWrapMode(QRhiSampler::AddressMode m) return GL_CLAMP_TO_EDGE; case QRhiSampler::Mirror: return GL_MIRRORED_REPEAT; - case QRhiSampler::MirrorOnce: - Q_FALLTHROUGH(); - case QRhiSampler::Border: - qWarning("Unsupported wrap mode %d", m); - return GL_CLAMP_TO_EDGE; default: Q_UNREACHABLE(); return GL_CLAMP_TO_EDGE; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 131b2da802..06e81465a2 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -41,6 +41,8 @@ #ifdef Q_OS_MACOS #include +#else +#include #endif #include @@ -318,7 +320,13 @@ struct QMetalComputePipelineData struct QMetalSwapChainData { + // The iOS simulator's headers mark CAMetalLayer as iOS 13.0+ only. + // (for real device SDKs it is 8.0+) +#ifdef TARGET_IPHONE_SIMULATOR + API_AVAILABLE(ios(13.0)) CAMetalLayer *layer = nullptr; +#else CAMetalLayer *layer = nullptr; +#endif id curDrawable; dispatch_semaphore_t sem[QMTL_FRAMES_IN_FLIGHT]; MTLRenderPassDescriptor *rp = nullptr; @@ -1763,8 +1771,10 @@ void QRhiMetal::executeBufferHostWritesForCurrentFrame(QMetalBuffer *bufD) if (changeEnd == -1 || u.offset + u.data.size() > changeEnd) changeEnd = u.offset + u.data.size(); } +#ifdef Q_OS_MACOS if (changeBegin >= 0 && bufD->d->managed) [bufD->d->buf[idx] didModifyRange: NSMakeRange(NSUInteger(changeBegin), NSUInteger(changeEnd - changeBegin))]; +#endif bufD->d->pendingUpdates[idx].clear(); } @@ -1798,8 +1808,12 @@ void QRhiMetal::beginPass(QRhiCommandBuffer *cb, if (color0.needsDrawableForTex || color0.needsDrawableForResolveTex) { Q_ASSERT(currentSwapChain); QMetalSwapChain *swapChainD = QRHI_RES(QMetalSwapChain, currentSwapChain); - if (!swapChainD->d->curDrawable) - swapChainD->d->curDrawable = [swapChainD->d->layer nextDrawable]; + if (!swapChainD->d->curDrawable) { +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) +#endif + swapChainD->d->curDrawable = [swapChainD->d->layer nextDrawable]; + } if (!swapChainD->d->curDrawable) { qWarning("No drawable"); return; @@ -2170,12 +2184,13 @@ bool QMetalRenderBuffer::build() case DepthStencil: #ifdef Q_OS_MACOS desc.storageMode = MTLStorageModePrivate; + d->format = rhiD->d->dev.depth24Stencil8PixelFormatSupported + ? MTLPixelFormatDepth24Unorm_Stencil8 : MTLPixelFormatDepth32Float_Stencil8; #else - desc.storageMode = MTLResourceStorageModeMemoryless; + desc.storageMode = MTLStorageModeMemoryless; transientBacking = true; + d->format = MTLPixelFormatDepth32Float_Stencil8; #endif - d->format = rhiD->d->dev.depth24Stencil8PixelFormatSupported - ? MTLPixelFormatDepth24Unorm_Stencil8 : MTLPixelFormatDepth32Float_Stencil8; desc.pixelFormat = d->format; break; case Color: @@ -2569,12 +2584,8 @@ static inline MTLSamplerAddressMode toMetalAddressMode(QRhiSampler::AddressMode return MTLSamplerAddressModeRepeat; case QRhiSampler::ClampToEdge: return MTLSamplerAddressModeClampToEdge; - case QRhiSampler::Border: - return MTLSamplerAddressModeClampToBorderColor; case QRhiSampler::Mirror: return MTLSamplerAddressModeMirrorRepeat; - case QRhiSampler::MirrorOnce: - return MTLSamplerAddressModeMirrorClampToEdge; default: Q_UNREACHABLE(); return MTLSamplerAddressModeClampToEdge; @@ -3311,7 +3322,11 @@ bool QMetalGraphicsPipeline::build() // validation blows up otherwise. MTLPixelFormat fmt = MTLPixelFormat(rpD->dsFormat); rpDesc.depthAttachmentPixelFormat = fmt; +#ifdef Q_OS_MACOS if (fmt != MTLPixelFormatDepth16Unorm && fmt != MTLPixelFormatDepth32Float) +#else + if (fmt != MTLPixelFormatDepth32Float) +#endif rpDesc.stencilAttachmentPixelFormat = fmt; } @@ -3528,6 +3543,10 @@ QMetalSwapChain::~QMetalSwapChain() void QMetalSwapChain::release() { +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) { +#endif + if (!d->layer) return; @@ -3556,6 +3575,10 @@ void QMetalSwapChain::release() QRHI_PROF_F(releaseSwapChain(this)); rhiD->unregisterResource(this); + +#ifdef TARGET_IPHONE_SIMULATOR + } +#endif } QRhiCommandBuffer *QMetalSwapChain::currentFrameCommandBuffer() @@ -3578,16 +3601,20 @@ QRhiRenderPassDescriptor *QMetalSwapChain::newCompatibleRenderPassDescriptor() { chooseFormats(); // ensure colorFormat and similar are filled out - QRHI_RES_RHI(QRhiMetal); QMetalRenderPassDescriptor *rpD = new QMetalRenderPassDescriptor(m_rhi); rpD->colorAttachmentCount = 1; rpD->hasDepthStencil = m_depthStencil != nullptr; rpD->colorFormat[0] = int(d->colorFormat); +#ifdef Q_OS_MACOS // m_depthStencil may not be built yet so cannot rely on computed fields in it + QRHI_RES_RHI(QRhiMetal); rpD->dsFormat = rhiD->d->dev.depth24Stencil8PixelFormatSupported ? MTLPixelFormatDepth24Unorm_Stencil8 : MTLPixelFormatDepth32Float_Stencil8; +#else + rpD->dsFormat = MTLPixelFormatDepth32Float_Stencil8; +#endif return rpD; } @@ -3603,6 +3630,10 @@ void QMetalSwapChain::chooseFormats() bool QMetalSwapChain::buildOrResize() { +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) { +#endif + Q_ASSERT(m_window); const bool needsRegistration = !window || window != m_window; @@ -3622,7 +3653,11 @@ bool QMetalSwapChain::buildOrResize() return false; } +#ifdef Q_OS_MACOS NSView *view = reinterpret_cast(window->winId()); +#else + UIView *view = reinterpret_cast(window->winId()); +#endif Q_ASSERT(view); d->layer = static_cast(view.layer); Q_ASSERT(d->layer); @@ -3726,6 +3761,15 @@ bool QMetalSwapChain::buildOrResize() rhiD->registerResource(this); return true; + +#ifdef TARGET_IPHONE_SIMULATOR + } else { + // Won't ever get here in a normal app because MTLDevice creation would + // fail too. Print a warning, just in case. + qWarning("No CAMetalLayer support in this version of the iOS Simulator"); + return false; + } +#endif } QT_END_NAMESPACE diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 2d69abb36b..f60c2d538e 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -4617,12 +4617,8 @@ static inline VkSamplerAddressMode toVkAddressMode(QRhiSampler::AddressMode m) return VK_SAMPLER_ADDRESS_MODE_REPEAT; case QRhiSampler::ClampToEdge: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; - case QRhiSampler::Border: - return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; case QRhiSampler::Mirror: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; - case QRhiSampler::MirrorOnce: - return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; default: Q_UNREACHABLE(); return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; diff --git a/src/gui/rhi/rhi.pri b/src/gui/rhi/rhi.pri index 4297a5602b..ccd9592634 100644 --- a/src/gui/rhi/rhi.pri +++ b/src/gui/rhi/rhi.pri @@ -43,15 +43,15 @@ win32 { LIBS += -ld3d11 -ldxgi -ldxguid } -# darwin { -macos { +macos|ios { HEADERS += \ rhi/qrhimetal_p.h \ rhi/qrhimetal_p_p.h SOURCES += \ rhi/qrhimetal.mm - LIBS += -framework AppKit -framework Metal + macos: LIBS += -framework AppKit + LIBS += -framework Metal } include($$PWD/../../3rdparty/VulkanMemoryAllocator.pri) -- cgit v1.2.3 From 64760504e79c3069d99b5e852688a2589ec22028 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 26 Nov 2019 12:43:56 +0100 Subject: rhi: Allow testing QRhiRenderPassDescriptors for compatibility For Metal and Vulkan this needs actual work because that's where the concept of renderpass descriptors is relevant. GL and D3D can just return true always. The big benefit of this is that Qt Quick can now compare renderpass descriptors via isCompatible() for its pipeline cache (similarly to how it is already using isLayoutCompatible() for srbs), and so renderpass descriptors for layers (Item.layer, ShaderEffect) will typically be compatible and so can pick up pipelines created by other layers from the cache. Also add autotests for shader resource binding and renderpass descriptor compatibility. Task-number: QTBUG-80318 Change-Id: I0008bc51c4ee13b0113d2c8caf799e1257f18a18 Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhi.cpp | 18 ++++ src/gui/rhi/qrhi_p.h | 1 + src/gui/rhi/qrhid3d11.cpp | 6 ++ src/gui/rhi/qrhid3d11_p_p.h | 1 + src/gui/rhi/qrhigles2.cpp | 6 ++ src/gui/rhi/qrhigles2_p_p.h | 1 + src/gui/rhi/qrhimetal.mm | 26 ++++++ src/gui/rhi/qrhimetal_p_p.h | 1 + src/gui/rhi/qrhinull.cpp | 6 ++ src/gui/rhi/qrhinull_p_p.h | 1 + src/gui/rhi/qrhivulkan.cpp | 193 ++++++++++++++++++++++++++++--------------- src/gui/rhi/qrhivulkan_p_p.h | 10 ++- 12 files changed, 202 insertions(+), 68 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index ac5836fc68..ece5190ff7 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2318,6 +2318,24 @@ QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const return RenderPassDescriptor; } +/*! + \fn bool QRhiRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const; + + \return true if the \a other QRhiRenderPassDescriptor is compatible with + this one, meaning \c this and \a other can be used interchangebly in + QRhiGraphicsPipeline::setRenderPassDescriptor(). + + The concept of the compatibility of renderpass descriptors is similar to + the \l{QRhiShaderResourceBindings::isLayoutCompatible}{layout + compatibility} of QRhiShaderResourceBindings instances. They allow better + reuse of QRhiGraphicsPipeline instances: for example, a + QRhiGraphicsPipeline instance cache is expected to use these functions to + look for a matching pipeline, instead of just comparing pointers, thus + allowing a different QRhiRenderPassDescriptor and + QRhiShaderResourceBindings to be used in combination with the pipeline, as + long as they are compatible. + */ + /*! \return a pointer to a backend-specific QRhiNativeHandles subclass, such as QRhiVulkanRenderPassNativeHandles. The returned value is null when exposing diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 8cc4c7a06c..9df2c58962 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -911,6 +911,7 @@ class Q_GUI_EXPORT QRhiRenderPassDescriptor : public QRhiResource public: QRhiResource::Type resourceType() const override; + virtual bool isCompatible(const QRhiRenderPassDescriptor *other) const = 0; virtual const QRhiNativeHandles *nativeHandles(); protected: diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 7e05aefe8d..52109edce0 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -2940,6 +2940,12 @@ void QD3D11RenderPassDescriptor::release() // nothing to do here } +bool QD3D11RenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + Q_UNUSED(other); + return true; +} + QD3D11ReferenceRenderTarget::QD3D11ReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(rhi) diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index 26de34ae0a..13c56b1d6d 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -136,6 +136,7 @@ struct QD3D11RenderPassDescriptor : public QRhiRenderPassDescriptor QD3D11RenderPassDescriptor(QRhiImplementation *rhi); ~QD3D11RenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; }; struct QD3D11RenderTargetData diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index ab61050e3e..b0e9a149f1 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3455,6 +3455,12 @@ void QGles2RenderPassDescriptor::release() // nothing to do here } +bool QGles2RenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + Q_UNUSED(other); + return true; +} + QGles2ReferenceRenderTarget::QGles2ReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(rhi) diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index cc945876e6..b0f5e340fb 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -185,6 +185,7 @@ struct QGles2RenderPassDescriptor : public QRhiRenderPassDescriptor QGles2RenderPassDescriptor(QRhiImplementation *rhi); ~QGles2RenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; }; struct QGles2RenderTargetData diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 06e81465a2..e5af1cfab1 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -2658,6 +2658,32 @@ void QMetalRenderPassDescriptor::release() // nothing to do here } +bool QMetalRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + if (!other) + return false; + + const QMetalRenderPassDescriptor *o = QRHI_RES(const QMetalRenderPassDescriptor, other); + + if (colorAttachmentCount != o->colorAttachmentCount) + return false; + + if (hasDepthStencil != o->hasDepthStencil) + return false; + + for (int i = 0; i < colorAttachmentCount; ++i) { + if (colorFormat[i] != o->colorFormat[i]) + return false; + } + + if (hasDepthStencil) { + if (dsFormat != o->dsFormat) + return false; + } + + return true; +} + QMetalReferenceRenderTarget::QMetalReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(new QMetalRenderTargetData) diff --git a/src/gui/rhi/qrhimetal_p_p.h b/src/gui/rhi/qrhimetal_p_p.h index 2be86db5c8..7876539fcd 100644 --- a/src/gui/rhi/qrhimetal_p_p.h +++ b/src/gui/rhi/qrhimetal_p_p.h @@ -138,6 +138,7 @@ struct QMetalRenderPassDescriptor : public QRhiRenderPassDescriptor QMetalRenderPassDescriptor(QRhiImplementation *rhi); ~QMetalRenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; // there is no MTLRenderPassDescriptor here as one will be created for each pass in beginPass() diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index fe606f971f..0baea1b9d6 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -690,6 +690,12 @@ void QNullRenderPassDescriptor::release() { } +bool QNullRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + Q_UNUSED(other); + return true; +} + QNullReferenceRenderTarget::QNullReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(rhi) diff --git a/src/gui/rhi/qrhinull_p_p.h b/src/gui/rhi/qrhinull_p_p.h index ce517bfa63..c96f279f7d 100644 --- a/src/gui/rhi/qrhinull_p_p.h +++ b/src/gui/rhi/qrhinull_p_p.h @@ -101,6 +101,7 @@ struct QNullRenderPassDescriptor : public QRhiRenderPassDescriptor QNullRenderPassDescriptor(QRhiImplementation *rhi); ~QNullRenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; }; struct QNullRenderTargetData diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index f60c2d538e..25a85a5a17 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1032,54 +1032,62 @@ VkFormat QRhiVulkan::optimalDepthStencilFormat() return optimalDsFormat; } -bool QRhiVulkan::createDefaultRenderPass(VkRenderPass *rp, bool hasDepthStencil, VkSampleCountFlagBits samples, VkFormat colorFormat) +bool QRhiVulkan::createDefaultRenderPass(QVkRenderPassDescriptor *rpD, bool hasDepthStencil, VkSampleCountFlagBits samples, VkFormat colorFormat) { - VkAttachmentDescription attDesc[3]; - memset(attDesc, 0, sizeof(attDesc)); - // attachment list layout is color (1), ds (0-1), resolve (0-1) - attDesc[0].format = colorFormat; - attDesc[0].samples = samples; - attDesc[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - attDesc[0].storeOp = samples > VK_SAMPLE_COUNT_1_BIT ? VK_ATTACHMENT_STORE_OP_DONT_CARE : VK_ATTACHMENT_STORE_OP_STORE; - attDesc[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - attDesc[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attDesc[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - attDesc[0].finalLayout = samples > VK_SAMPLE_COUNT_1_BIT ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - - // clear on load + no store + lazy alloc + transient image should play - // nicely with tiled GPUs (no physical backing necessary for ds buffer) - attDesc[1].format = optimalDepthStencilFormat(); - attDesc[1].samples = samples; - attDesc[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - attDesc[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attDesc[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - attDesc[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attDesc[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - attDesc[1].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + VkAttachmentDescription attDesc; + memset(&attDesc, 0, sizeof(attDesc)); + attDesc.format = colorFormat; + attDesc.samples = samples; + attDesc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + attDesc.storeOp = samples > VK_SAMPLE_COUNT_1_BIT ? VK_ATTACHMENT_STORE_OP_DONT_CARE : VK_ATTACHMENT_STORE_OP_STORE; + attDesc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + attDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + attDesc.finalLayout = samples > VK_SAMPLE_COUNT_1_BIT ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + rpD->attDescs.append(attDesc); - if (samples > VK_SAMPLE_COUNT_1_BIT) { - attDesc[2].format = colorFormat; - attDesc[2].samples = VK_SAMPLE_COUNT_1_BIT; - attDesc[2].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - attDesc[2].storeOp = VK_ATTACHMENT_STORE_OP_STORE; - attDesc[2].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - attDesc[2].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attDesc[2].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - attDesc[2].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + rpD->colorRefs.append({ 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }); + + if (hasDepthStencil) { + // clear on load + no store + lazy alloc + transient image should play + // nicely with tiled GPUs (no physical backing necessary for ds buffer) + memset(&attDesc, 0, sizeof(attDesc)); + attDesc.format = optimalDepthStencilFormat(); + attDesc.samples = samples; + attDesc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + attDesc.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attDesc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + attDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + attDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + rpD->attDescs.append(attDesc); + + rpD->dsRef = { 1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; } - VkAttachmentReference colorRef = { 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; - VkAttachmentReference dsRef = { 1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; - VkAttachmentReference resolveRef = { 2, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; + if (samples > VK_SAMPLE_COUNT_1_BIT) { + memset(&attDesc, 0, sizeof(attDesc)); + attDesc.format = colorFormat; + attDesc.samples = VK_SAMPLE_COUNT_1_BIT; + attDesc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + attDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; + attDesc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + attDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + attDesc.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + rpD->attDescs.append(attDesc); + + rpD->resolveRefs.append({ 2, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }); + } VkSubpassDescription subpassDesc; memset(&subpassDesc, 0, sizeof(subpassDesc)); subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; subpassDesc.colorAttachmentCount = 1; - subpassDesc.pColorAttachments = &colorRef; - subpassDesc.pDepthStencilAttachment = hasDepthStencil ? &dsRef : nullptr; + subpassDesc.pColorAttachments = rpD->colorRefs.constData(); + subpassDesc.pDepthStencilAttachment = hasDepthStencil ? &rpD->dsRef : nullptr; // Replace the first implicit dep (TOP_OF_PIPE / ALL_COMMANDS) with our own. VkSubpassDependency subpassDep; @@ -1095,7 +1103,7 @@ bool QRhiVulkan::createDefaultRenderPass(VkRenderPass *rp, bool hasDepthStencil, memset(&rpInfo, 0, sizeof(rpInfo)); rpInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; rpInfo.attachmentCount = 1; - rpInfo.pAttachments = attDesc; + rpInfo.pAttachments = rpD->attDescs.constData(); rpInfo.subpassCount = 1; rpInfo.pSubpasses = &subpassDesc; rpInfo.dependencyCount = 1; @@ -1106,19 +1114,21 @@ bool QRhiVulkan::createDefaultRenderPass(VkRenderPass *rp, bool hasDepthStencil, if (samples > VK_SAMPLE_COUNT_1_BIT) { rpInfo.attachmentCount += 1; - subpassDesc.pResolveAttachments = &resolveRef; + subpassDesc.pResolveAttachments = rpD->resolveRefs.constData(); } - VkResult err = df->vkCreateRenderPass(dev, &rpInfo, nullptr, rp); + VkResult err = df->vkCreateRenderPass(dev, &rpInfo, nullptr, &rpD->rp); if (err != VK_SUCCESS) { qWarning("Failed to create renderpass: %d", err); return false; } + rpD->hasDepthStencil = hasDepthStencil; + return true; } -bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, +bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, const QRhiColorAttachment *firstColorAttachment, const QRhiColorAttachment *lastColorAttachment, bool preserveColor, @@ -1126,10 +1136,6 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, QRhiRenderBuffer *depthStencilBuffer, QRhiTexture *depthTexture) { - QVarLengthArray attDescs; - QVarLengthArray colorRefs; - QVarLengthArray resolveRefs; - // attachment list layout is color (0-8), ds (0-1), resolve (0-8) for (auto it = firstColorAttachment; it != lastColorAttachment; ++it) { @@ -1150,14 +1156,14 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, // this has to interact correctly with activateTextureRenderTarget(), hence leaving in COLOR_ATT attDesc.initialLayout = preserveColor ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED; attDesc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - attDescs.append(attDesc); + rpD->attDescs.append(attDesc); - const VkAttachmentReference ref = { uint32_t(attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; - colorRefs.append(ref); + const VkAttachmentReference ref = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; + rpD->colorRefs.append(ref); } - const bool hasDepthStencil = depthStencilBuffer || depthTexture; - if (hasDepthStencil) { + rpD->hasDepthStencil = depthStencilBuffer || depthTexture; + if (rpD->hasDepthStencil) { const VkFormat dsFormat = depthTexture ? QRHI_RES(QVkTexture, depthTexture)->vkformat : QRHI_RES(QVkRenderBuffer, depthStencilBuffer)->vkformat; const VkSampleCountFlagBits samples = depthTexture ? QRHI_RES(QVkTexture, depthTexture)->samples @@ -1174,9 +1180,9 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, attDesc.stencilStoreOp = storeOp; attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; attDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; - attDescs.append(attDesc); + rpD->attDescs.append(attDesc); } - VkAttachmentReference dsRef = { uint32_t(attDescs.count() - 1), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; + rpD->dsRef = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; for (auto it = firstColorAttachment; it != lastColorAttachment; ++it) { if (it->resolveTexture()) { @@ -1194,37 +1200,37 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, attDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; attDesc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - attDescs.append(attDesc); + rpD->attDescs.append(attDesc); - const VkAttachmentReference ref = { uint32_t(attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; - resolveRefs.append(ref); + const VkAttachmentReference ref = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; + rpD->resolveRefs.append(ref); } else { const VkAttachmentReference ref = { VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; - resolveRefs.append(ref); + rpD->resolveRefs.append(ref); } } VkSubpassDescription subpassDesc; memset(&subpassDesc, 0, sizeof(subpassDesc)); subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; - subpassDesc.colorAttachmentCount = uint32_t(colorRefs.count()); - Q_ASSERT(colorRefs.count() == resolveRefs.count()); - subpassDesc.pColorAttachments = !colorRefs.isEmpty() ? colorRefs.constData() : nullptr; - subpassDesc.pDepthStencilAttachment = hasDepthStencil ? &dsRef : nullptr; - subpassDesc.pResolveAttachments = !resolveRefs.isEmpty() ? resolveRefs.constData() : nullptr; + subpassDesc.colorAttachmentCount = uint32_t(rpD->colorRefs.count()); + Q_ASSERT(rpD->colorRefs.count() == rpD->resolveRefs.count()); + subpassDesc.pColorAttachments = !rpD->colorRefs.isEmpty() ? rpD->colorRefs.constData() : nullptr; + subpassDesc.pDepthStencilAttachment = rpD->hasDepthStencil ? &rpD->dsRef : nullptr; + subpassDesc.pResolveAttachments = !rpD->resolveRefs.isEmpty() ? rpD->resolveRefs.constData() : nullptr; VkRenderPassCreateInfo rpInfo; memset(&rpInfo, 0, sizeof(rpInfo)); rpInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; - rpInfo.attachmentCount = uint32_t(attDescs.count()); - rpInfo.pAttachments = attDescs.constData(); + rpInfo.attachmentCount = uint32_t(rpD->attDescs.count()); + rpInfo.pAttachments = rpD->attDescs.constData(); rpInfo.subpassCount = 1; rpInfo.pSubpasses = &subpassDesc; // don't yet know the correct initial/final access and stage stuff for the // implicit deps at this point, so leave it to the resource tracking to // generate barriers - VkResult err = df->vkCreateRenderPass(dev, &rpInfo, nullptr, rp); + VkResult err = df->vkCreateRenderPass(dev, &rpInfo, nullptr, &rpD->rp); if (err != VK_SUCCESS) { qWarning("Failed to create renderpass: %d", err); return false; @@ -5501,6 +5507,61 @@ void QVkRenderPassDescriptor::release() rhiD->unregisterResource(this); } +static inline bool attachmentDescriptionEquals(const VkAttachmentDescription &a, const VkAttachmentDescription &b) +{ + return a.format == b.format + && a.samples == b.samples + && a.loadOp == b.loadOp + && a.storeOp == b.storeOp + && a.stencilLoadOp == b.stencilLoadOp + && a.stencilStoreOp == b.stencilStoreOp + && a.initialLayout == b.initialLayout + && a.finalLayout == b.finalLayout; +} + +bool QVkRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + if (!other) + return false; + + const QVkRenderPassDescriptor *o = QRHI_RES(const QVkRenderPassDescriptor, other); + + if (attDescs.count() != o->attDescs.count()) + return false; + if (colorRefs.count() != o->colorRefs.count()) + return false; + if (resolveRefs.count() != o->resolveRefs.count()) + return false; + if (hasDepthStencil != o->hasDepthStencil) + return false; + + for (int i = 0, ie = colorRefs.count(); i != ie; ++i) { + const uint32_t attIdx = colorRefs[i].attachment; + if (attIdx != o->colorRefs[i].attachment) + return false; + if (attIdx != VK_ATTACHMENT_UNUSED && !attachmentDescriptionEquals(attDescs[attIdx], o->attDescs[attIdx])) + return false; + } + + if (hasDepthStencil) { + const uint32_t attIdx = dsRef.attachment; + if (attIdx != o->dsRef.attachment) + return false; + if (attIdx != VK_ATTACHMENT_UNUSED && !attachmentDescriptionEquals(attDescs[attIdx], o->attDescs[attIdx])) + return false; + } + + for (int i = 0, ie = resolveRefs.count(); i != ie; ++i) { + const uint32_t attIdx = resolveRefs[i].attachment; + if (attIdx != o->resolveRefs[i].attachment) + return false; + if (attIdx != VK_ATTACHMENT_UNUSED && !attachmentDescriptionEquals(attDescs[attIdx], o->attDescs[attIdx])) + return false; + } + + return true; +} + const QRhiNativeHandles *QVkRenderPassDescriptor::nativeHandles() { nativeHandlesStruct.renderPass = rp; @@ -5584,7 +5645,7 @@ QRhiRenderPassDescriptor *QVkTextureRenderTarget::newCompatibleRenderPassDescrip QRHI_RES_RHI(QRhiVulkan); QVkRenderPassDescriptor *rp = new QVkRenderPassDescriptor(m_rhi); - if (!rhiD->createOffscreenRenderPass(&rp->rp, + if (!rhiD->createOffscreenRenderPass(rp, m_desc.cbeginColorAttachments(), m_desc.cendColorAttachments(), m_flags.testFlag(QRhiTextureRenderTarget::PreserveColorContents), @@ -6285,7 +6346,7 @@ QRhiRenderPassDescriptor *QVkSwapChain::newCompatibleRenderPassDescriptor() QRHI_RES_RHI(QRhiVulkan); QVkRenderPassDescriptor *rp = new QVkRenderPassDescriptor(m_rhi); - if (!rhiD->createDefaultRenderPass(&rp->rp, + if (!rhiD->createDefaultRenderPass(rp, m_depthStencil != nullptr, samples, colorFormat)) diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index d0e1e6758b..ffa8c59ed5 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -171,10 +171,16 @@ struct QVkRenderPassDescriptor : public QRhiRenderPassDescriptor QVkRenderPassDescriptor(QRhiImplementation *rhi); ~QVkRenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; const QRhiNativeHandles *nativeHandles() override; VkRenderPass rp = VK_NULL_HANDLE; bool ownsRp = false; + QVarLengthArray attDescs; + QVarLengthArray colorRefs; + QVarLengthArray resolveRefs; + bool hasDepthStencil = false; + VkAttachmentReference dsRef; QRhiVulkanRenderPassNativeHandles nativeHandlesStruct; int lastActiveFrameSlot = -1; }; @@ -727,11 +733,11 @@ public: VkFormat optimalDepthStencilFormat(); VkSampleCountFlagBits effectiveSampleCount(int sampleCount); - bool createDefaultRenderPass(VkRenderPass *rp, + bool createDefaultRenderPass(QVkRenderPassDescriptor *rpD, bool hasDepthStencil, VkSampleCountFlagBits samples, VkFormat colorFormat); - bool createOffscreenRenderPass(VkRenderPass *rp, + bool createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, const QRhiColorAttachment *firstColorAttachment, const QRhiColorAttachment *lastColorAttachment, bool preserveColor, -- cgit v1.2.3 From 20891777bb8b295a26e3fb2b9f5b2c59fcff66dd Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 6 Apr 2018 15:57:49 +1000 Subject: webassembly: enable opengl es3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our WebGL 2 support is half finished, since we use surface format verion of 3 to map to webgl2, but do not enable Open GL ES3 needed for WebGL2 support. This allows glDrawArrays and glDrawElements to be used Change-Id: Ifbd434f4d25e49f671145a6727999a90920d6810 Reviewed-by: Laszlo Agocs Reviewed-by: Morten Johan Sørvig --- src/gui/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/configure.json b/src/gui/configure.json index 134a2e0a15..7f4d7cc6af 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1315,7 +1315,7 @@ }, "opengles3": { "label": "OpenGL ES 3.0", - "condition": "features.opengles2 && !features.angle && tests.opengles3 && !config.wasm", + "condition": "features.opengles2 && !features.angle && tests.opengles3", "output": [ "publicFeature", { "type": "define", "name": "QT_OPENGL_ES_3" } -- cgit v1.2.3 From fc5dc8c16a57608ea824a7205f4dd7acc824d82f Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 25 Nov 2019 12:48:58 +0100 Subject: Improve QShortcutMap debug output Replace the macro with a logging category so that it's not necessary to patch Qt to get output about e.g. ambiguous shortcuts. Change-Id: I4d365aac5a5c0da8629447d93d3bc90c9c3076c2 Reviewed-by: Friedemann Kleint Reviewed-by: Volker Hilsheimer --- src/gui/kernel/qshortcutmap.cpp | 81 ++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 53 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 0395c1db38..9ed450b031 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -45,6 +45,7 @@ #include "qvector.h" #include "qcoreapplication.h" #include +#include #include @@ -52,8 +53,7 @@ QT_BEGIN_NAMESPACE -// To enable verbose output uncomment below -//#define DEBUG_QSHORTCUTMAP +Q_LOGGING_CATEGORY(lcShortcutMap, "qt.gui.shortcutmap") /* \internal Entry data for QShortcutMap @@ -165,11 +165,9 @@ int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::Short QShortcutEntry newEntry(owner, key, context, --(d->currentId), true, matcher); const auto it = std::upper_bound(d->sequences.begin(), d->sequences.end(), newEntry); d->sequences.insert(it, newEntry); // Insert sorted -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::addShortcut(" << owner << ", " << key << ", " << context << ") = " << d->currentId; -#endif return d->currentId; } @@ -212,11 +210,9 @@ int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key return itemsRemoved; --i; } -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::removeShortcut(" << id << ", " << owner << ", " << key << ") = " << itemsRemoved; -#endif return itemsRemoved; } @@ -250,11 +246,9 @@ int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const return itemsChanged; --i; } -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::setShortcutEnabled(" << enable << ", " << id << ", " << owner << ", " << key << ") = " << itemsChanged; -#endif return itemsChanged; } @@ -288,11 +282,9 @@ int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const Q return itemsChanged; --i; } -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::setShortcutAutoRepeat(" << on << ", " << id << ", " << owner << ", " << key << ") = " << itemsChanged; -#endif return itemsChanged; } @@ -395,9 +387,7 @@ QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e) clearSequence(d->currentSequences); d->currentState = result; -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() << "QShortcutMap::nextState(" << e << ") = " << result; -#endif + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::nextState(" << e << ") = " << result; return result; } @@ -436,9 +426,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier return QKeySequence::NoMatch; createNewSequences(e, d->newEntries, ignoredModifiers); -#if defined(DEBUG_QSHORTCUTMAP) - qDebug() << "Possible shortcut key sequences:" << d->newEntries; -#endif + qCDebug(lcShortcutMap) << "Possible shortcut key sequences:" << d->newEntries; // Should never happen if (d->newEntries == d->currentSequences) { @@ -491,15 +479,11 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier // previous list. If this match is equal or better than the last match, append to the list if (oneKSResult > result) { okEntries.clear(); -#if defined(DEBUG_QSHORTCUTMAP) - qDebug() << "Found better match (" << d->newEntries << "), clearing key sequence list"; -#endif + qCDebug(lcShortcutMap) << "Found better match (" << d->newEntries << "), clearing key sequence list"; } if (oneKSResult && oneKSResult >= result) { okEntries << d->newEntries.at(i); -#if defined(DEBUG_QSHORTCUTMAP) - qDebug() << "Added ok key sequence" << d->newEntries; -#endif + qCDebug(lcShortcutMap) << "Added ok key sequence" << d->newEntries; } } @@ -515,9 +499,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier } if (result != QKeySequence::NoMatch) d->currentSequences = okEntries; -#if defined(DEBUG_QSHORTCUTMAP) - qDebug() << "Returning shortcut match == " << result; -#endif + qCDebug(lcShortcutMap) << "Returning shortcut match == " << result; return QKeySequence::SequenceMatch(result); } @@ -540,19 +522,16 @@ void QShortcutMap::createNewSequences(QKeyEvent *e, QVector &ksl, { Q_D(QShortcutMap); QList possibleKeys = QKeyMapper::possibleKeys(e); -#if defined(DEBUG_QSHORTCUTMAP) - { - QDebug debug = qDebug().nospace(); - debug << __FUNCTION__ << '(' << e << ", ignoredModifiers=" + if (lcShortcutMap().isDebugEnabled()) { + qCDebug(lcShortcutMap).nospace() << __FUNCTION__ << '(' << e << ", ignoredModifiers=" << Qt::KeyboardModifiers(ignoredModifiers) << "), possibleKeys=("; for (int i = 0, size = possibleKeys.size(); i < size; ++i) { if (i) - debug << ", "; - debug << QKeySequence(possibleKeys.at(i)); + qCDebug(lcShortcutMap).nospace() << ", "; + qCDebug(lcShortcutMap).nospace() << QKeySequence(possibleKeys.at(i)); } - debug << ')'; + qCDebug(lcShortcutMap).nospace() << ')'; } -#endif // DEBUG_QSHORTCUTMAP int pkTotal = possibleKeys.count(); if (!pkTotal) return; @@ -661,16 +640,13 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e) // Find next const QShortcutEntry *current = 0, *next = 0; int i = 0, enabledShortcuts = 0; -#if defined(DEBUG_QSHORTCUTMAP) QVector ambiguousShortcuts; -#endif while(i < d->identicals.size()) { current = d->identicals.at(i); if (current->enabled || !next){ ++enabledShortcuts; -#if defined(DEBUG_QSHORTCUTMAP) - ambiguousShortcuts.append(current); -#endif + if (lcShortcutMap().isDebugEnabled()) + ambiguousShortcuts.append(current); if (enabledShortcuts > d->ambigCount + 1) break; next = current; @@ -683,19 +659,18 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e) if (!next || (e->isAutoRepeat() && !next->autorepeat)) return; // Dispatch next enabled -#if defined(DEBUG_QSHORTCUTMAP) - if (ambiguousShortcuts.size() > 1) { - qDebug() << "The following shortcuts are about to be activated ambiguously:"; - for (const QShortcutEntry *entry : qAsConst(ambiguousShortcuts)) { - qDebug().nospace() << "- " << entry->keyseq << " (belonging to " << entry->owner << ")"; + if (lcShortcutMap().isDebugEnabled()) { + if (ambiguousShortcuts.size() > 1) { + qCDebug(lcShortcutMap) << "The following shortcuts are about to be activated ambiguously:"; + for (const QShortcutEntry *entry : qAsConst(ambiguousShortcuts)) + qCDebug(lcShortcutMap).nospace() << "- " << entry->keyseq << " (belonging to " << entry->owner << ")"; } - } - qDebug().nospace() - << "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\"" - << next->keyseq.toString() << "\", " << next->id << ", " - << (bool)(enabledShortcuts>1) << ") to object(" << next->owner << ')'; -#endif + qCDebug(lcShortcutMap).nospace() + << "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\"" + << next->keyseq.toString() << "\", " << next->id << ", " + << static_cast(enabledShortcuts>1) << ") to object(" << next->owner << ')'; + } QShortcutEvent se(next->keyseq, next->id, enabledShortcuts>1); QCoreApplication::sendEvent(const_cast(next->owner), &se); } -- cgit v1.2.3 From ee3e0ed751e8acdd5f1cefb430b0981c21f71f8e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 25 Nov 2019 11:15:22 +0100 Subject: rhi: gl: Fix ms renderbuffer on WASM with WebGL2 Unlike renderbufferStorage, renderbufferStorageMultisample is not guaranteed to accept the unsized GL_DEPTH_STENCIL internalformat. For the former, WebGL 2 guarantees it for compatibility for WebGL 1, but the multisample version does not exist in WebGL 1, so from the specs it is not given at all that the unsized format would be accepted. So use the ES 3.0 sized format instead, like we would on a "real" ES 3.0 implementation. Fixes: QTBUG-80296 Change-Id: I822ae382097085c0a3279c16bb69a173dbf15093 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhigles2.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index abee843a74..b394354787 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3147,8 +3147,7 @@ bool QGles2RenderBuffer::build() switch (m_type) { case QRhiRenderBuffer::DepthStencil: if (rhiD->caps.msaaRenderBuffer && samples > 1) { - const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8; - rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, storage, + rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, size.width(), size.height()); stencilRenderbuffer = 0; } else if (rhiD->caps.packedDepthStencil || rhiD->caps.needsDepthStencilCombinedAttach) { -- cgit v1.2.3 From 9fd217e7467fa5f82340c30b1b6bb28557057919 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 27 Nov 2019 12:46:28 +0100 Subject: Silence intel compiler warning about float comparison Add the equivalent intel warning macro in public header where there was already the macro for -Wfloat-equal Change-Id: I8f20400f0b95c8f3857fa7a0a33464c8c34d5c0e Reviewed-by: Thiago Macieira --- src/gui/math3d/qmatrix4x4.h | 1 + src/gui/math3d/qquaternion.h | 1 + src/gui/math3d/qvector2d.h | 1 + src/gui/math3d/qvector3d.h | 1 + src/gui/math3d/qvector4d.h | 1 + src/gui/painting/qtransform.h | 1 + 6 files changed, 6 insertions(+) (limited to 'src/gui') diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 69c3510659..1439bfac59 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -215,6 +215,7 @@ private: QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECLARE_TYPEINFO(QMatrix4x4, Q_MOVABLE_TYPE); inline QMatrix4x4::QMatrix4x4 diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index cd0d746e55..f01fab679e 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -171,6 +171,7 @@ inline QQuaternion::QQuaternion(float aScalar, float xpos, float ypos, float zpo QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) inline bool QQuaternion::isNull() const { return wp == 0.0f && xp == 0.0f && yp == 0.0f && zp == 0.0f; diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index 88d8bc199e..cbce94c199 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -207,6 +207,7 @@ inline QVector2D &QVector2D::operator/=(const QVector2D &vector) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECL_CONSTEXPR inline bool operator==(const QVector2D &v1, const QVector2D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1]; diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h index 1b49f3e7b9..d7ffb0bcc4 100644 --- a/src/gui/math3d/qvector3d.h +++ b/src/gui/math3d/qvector3d.h @@ -232,6 +232,7 @@ inline QVector3D &QVector3D::operator/=(const QVector3D &vector) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECL_CONSTEXPR inline bool operator==(const QVector3D &v1, const QVector3D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2]; diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 08cb423484..afcc71fa88 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -232,6 +232,7 @@ inline QVector4D &QVector4D::operator/=(const QVector4D &vector) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECL_CONSTEXPR inline bool operator==(const QVector4D &v1, const QVector4D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2] && v1.v[3] == v2.v[3]; diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index b220770144..b2a634dd2a 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -303,6 +303,7 @@ inline qreal QTransform::dy() const QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) inline QTransform &QTransform::operator*=(qreal num) { -- cgit v1.2.3 From 5b1a4578f545d5181265d9120b48bc92753b63b9 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Wed, 27 Nov 2019 20:27:19 +0100 Subject: wasm: Disable TextureSwizzle The WebGL 2.0 specification explicitly does not support texture swizzles. Therefore, disabling it when targeting WASM. This fixes "WebGL: INVALID_ENUM: texParameter: invalid parameter name" when running in Chrome or Firefox. Change-Id: Ic7e22e0f623095245274924095cb63fd0ff7e8c2 Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.19 Fixes: QTBUG-80287 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglfunctions.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 8ec814296a..bc3a4f7c1d 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -388,8 +388,12 @@ static int qt_gl_resolve_extensions() | QOpenGLExtensions::MapBufferRange | QOpenGLExtensions::FramebufferBlit | QOpenGLExtensions::FramebufferMultisample - | QOpenGLExtensions::Sized8Formats - | QOpenGLExtensions::TextureSwizzle; + | QOpenGLExtensions::Sized8Formats; +#ifndef Q_OS_WASM + // WebGL 2.0 specification explicitly does not support texture swizzles + // https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.19 + extensions |= QOpenGLExtensions::TextureSwizzle; +#endif } else { // Recognize features by extension name. if (extensionMatcher.match("GL_OES_packed_depth_stencil")) -- cgit v1.2.3 From 9feb20e58128ae7e8d208847ce989b65cdfcf5bc Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 4 Nov 2019 16:37:11 +0100 Subject: Remove convert_ARGB_PM_to_ARGB It was only used by conversions to indexed8 and mono, and is slower than the generic conversion which is optimized. Change-Id: I0480c5a1b5fa2de7e3c87fd621064dace46e5945 Reviewed-by: Eirik Aavitsland --- src/gui/image/qimage_conversions.cpp | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 7cd71644a3..8f33a13b95 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -851,30 +851,6 @@ static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConver return true; } -static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src) -{ - Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied || src->format == QImage::Format_RGBA8888_Premultiplied); - Q_ASSERT(dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_RGBA8888); - Q_ASSERT(src->width == dest->width); - Q_ASSERT(src->height == dest->height); - - const int src_pad = (src->bytes_per_line >> 2) - src->width; - const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; - const QRgb *src_data = (QRgb *) src->data; - QRgb *dest_data = (QRgb *) dest->data; - - for (int i = 0; i < src->height; ++i) { - const QRgb *end = src_data + src->width; - while (src_data < end) { - *dest_data = qUnpremultiply(*src_data); - ++src_data; - ++dest_data; - } - src_data += src_pad; - dest_data += dest_pad; - } -} - static void convert_RGBA_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) { Q_ASSERT(src->format == QImage::Format_RGBA8888 || src->format == QImage::Format_RGBX8888); @@ -1541,7 +1517,7 @@ static void convert_X_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageC static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) { QScopedPointer tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); - convert_ARGB_PM_to_ARGB(tmp.data(), src); + convert_generic(tmp.data(), src, Qt::AutoColor); dither_to_Mono(dst, tmp.data(), flags, false); } @@ -1821,7 +1797,7 @@ static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt:: static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) { QScopedPointer tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); - convert_ARGB_PM_to_ARGB(tmp.data(), src); + convert_generic(tmp.data(), src, Qt::AutoColor); convert_RGB_to_Indexed8(dst, tmp.data(), flags); } -- cgit v1.2.3 From 0f812db558df072a411ade3305b796d54bccd996 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 29 Nov 2019 10:43:20 +0100 Subject: rhi: vulkan: Remove unused include QVulkanWindow support has long been removed from the Vulkan backend. The include is a leftover from those times. Change-Id: Ie68ac3611b24310f2b6111a72dd0679adafdc74d Reviewed-by: Johan Helsing --- src/gui/rhi/qrhivulkan.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 103fea627a..444a395ebc 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -48,7 +48,6 @@ #include #include -#include QT_BEGIN_NAMESPACE -- cgit v1.2.3 From b63141fb1496e528e0e155513a5d4e954b0a1565 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 2 Dec 2019 09:14:19 +0100 Subject: RHI/Vulkan: Fix build Add missing include, fixing: rhi\qrhivulkan.cpp(6273): error C2027: use of undefined type 'QWindow' Amends 0f812db558df072a411ade3305b796d54bccd996. Change-Id: Ide61b713e958877f18a45a89b36a4e1330f75821 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhivulkan.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 444a395ebc..a200a6e271 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -48,6 +48,7 @@ #include #include +#include QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 443ef0010ae68ac5a883fb9ab7677d9de719e70e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 29 Nov 2019 10:50:24 +0100 Subject: rhi: Remove unused compat functions These were kept around to keep Qt Quick compiling, but the migration there has been done a long time ago. Remove these leftovers now. Change-Id: Ibd47381b410b11b5475a85c7ed3cb05c22f7adbb Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhi_p.h | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 907924c788..588347d111 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -246,10 +246,6 @@ public: m_bindings.clear(); std::copy(first, last, std::back_inserter(m_bindings)); } - void setBindings(const QVector &bindings) // compat., to be removed - { - setBindings(bindings.cbegin(), bindings.cend()); - } const QRhiVertexInputBinding *cbeginBindings() const { return m_bindings.cbegin(); } const QRhiVertexInputBinding *cendBindings() const { return m_bindings.cend(); } const QRhiVertexInputBinding *bindingAt(int index) const { return &m_bindings.at(index); } @@ -261,10 +257,6 @@ public: m_attributes.clear(); std::copy(first, last, std::back_inserter(m_attributes)); } - void setAttributes(const QVector &attributes) // compat., to be removed - { - setAttributes(attributes.cbegin(), attributes.cend()); - } const QRhiVertexInputAttribute *cbeginAttributes() const { return m_attributes.cbegin(); } const QRhiVertexInputAttribute *cendAttributes() const { return m_attributes.cend(); } @@ -551,9 +543,6 @@ public: QRhiTextureUploadDescription() = default; QRhiTextureUploadDescription(const QRhiTextureUploadEntry &entry); QRhiTextureUploadDescription(std::initializer_list list); - QRhiTextureUploadDescription(const QVector &entries) // compat., to be removed - : m_entries(entries.cbegin(), entries.cend()) - { } void setEntries(std::initializer_list list) { m_entries = list; } template @@ -979,11 +968,6 @@ public: std::copy(first, last, std::back_inserter(m_bindings)); } - void setBindings(const QVector &bindings) // compat., to be removed - { - setBindings(bindings.cbegin(), bindings.cend()); - } - const QRhiShaderResourceBinding *cbeginBindings() const { return m_bindings.cbegin(); } const QRhiShaderResourceBinding *cendBindings() const { return m_bindings.cend(); } @@ -1172,10 +1156,6 @@ public: m_shaderStages.clear(); std::copy(first, last, std::back_inserter(m_shaderStages)); } - void setShaderStages(const QVector &stages) // compat., to be removed - { - setShaderStages(stages.cbegin(), stages.cend()); - } const QRhiShaderStage *cbeginShaderStages() const { return m_shaderStages.cbegin(); } const QRhiShaderStage *cendShaderStages() const { return m_shaderStages.cend(); } -- cgit v1.2.3 From 9f79ab360fd8a504601d3c66a7773eeaa09bffde Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 3 Mar 2019 14:55:20 +0100 Subject: Fix assert in QTextDocument CSS parser on "border-width: 1pt" The code was assuming that if the parsing of the value worked, then it must be a list of 4 variants. But in this case it's just a single length. This came from using 4 values for border-width while other elements use a single value. But the storage is shared. So the fix is to use 4 values everywhere. When reading 4 and there's only one, it gets duplicated, so the caller can just use the first one in that case. Task-number: QTBUG-80496 Change-Id: I682244b6e3781c4d673a62d5e6511dac263c58e8 Reviewed-by: Nils Jeisecke Reviewed-by: Shawn Rutledge --- src/gui/text/qcssparser.cpp | 1 + src/gui/text/qcssparser_p.h | 4 ++-- src/gui/text/qtexthtmlparser.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index ce7c7610c1..627b3ec8c0 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -443,6 +443,7 @@ void ValueExtractor::lengthValues(const Declaration &decl, int *m) { if (decl.d->parsed.isValid()) { QList v = decl.d->parsed.toList(); + Q_ASSERT(v.size() == 4); for (int i = 0; i < 4; i++) m[i] = lengthValueFromData(qvariant_cast(v.at(i)), f); return; diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index ab85e76cf3..d91b095a76 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -856,13 +856,13 @@ struct Q_GUI_EXPORT ValueExtractor int extractStyleFeatures(); bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size); - int lengthValue(const Declaration &decl); + void lengthValues(const Declaration &decl, int *m); private: void extractFont(); void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color); LengthData lengthValue(const Value& v); - void lengthValues(const Declaration &decl, int *m); + int lengthValue(const Declaration &decl); QSize sizeValue(const Declaration &decl); void sizeValues(const Declaration &decl, QSize *radii); diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 5d37982a8b..b867f42480 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1209,8 +1209,11 @@ void QTextHtmlParserNode::applyCssDeclarations(const QVector if (decl.styleValue() != QCss::BorderStyle_Unknown && decl.styleValue() != QCss::BorderStyle_Native) borderStyle = static_cast(decl.styleValue() - 1); break; - case QCss::BorderWidth: - tableBorder = extractor.lengthValue(decl); + case QCss::BorderWidth: { + int borders[4]; + extractor.lengthValues(decl, borders); + tableBorder = borders[0]; + } break; case QCss::BorderCollapse: borderCollapse = decl.borderCollapseValue(); -- cgit v1.2.3 From 913146ccd401216f71f037ea304b5e61b7a138cf Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 29 Nov 2019 12:41:38 +0100 Subject: RHI: new native texture API The new version takes/returns a value that can be unpacked and passed to other functions without knowing which backend is in use. The old API will be removed in a later change when dependent modules have been updated Task-number: QTBUG-78570 Change-Id: I18d928ceef3cb617c0c509ecccb345551a7990af Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhi.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++ src/gui/rhi/qrhi_p.h | 7 +++++ src/gui/rhi/qrhid3d11.cpp | 28 ++++++++++++++++++ src/gui/rhi/qrhid3d11_p_p.h | 2 ++ src/gui/rhi/qrhigles2.cpp | 29 +++++++++++++++++++ src/gui/rhi/qrhigles2_p_p.h | 2 ++ src/gui/rhi/qrhimetal.mm | 29 +++++++++++++++++++ src/gui/rhi/qrhimetal_p_p.h | 2 ++ src/gui/rhi/qrhinull.cpp | 6 ++++ src/gui/rhi/qrhinull_p_p.h | 1 + src/gui/rhi/qrhivulkan.cpp | 30 ++++++++++++++++++++ src/gui/rhi/qrhivulkan_p_p.h | 2 ++ 12 files changed, 205 insertions(+) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index ece5190ff7..58f30deb41 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2159,6 +2159,32 @@ QRhiResource::Type QRhiRenderBuffer::resourceType() const \value ASTC_12x12 */ +/*! + \class QRhiTexture::NativeTexture + \brief Contains information about the underlying native resources of a texture. + */ + +/*! + \variable QRhiTexture::NativeTexture::object + \brief a pointer to the native object handle. + + With OpenGL, the native handle is a GLuint value, so \c object is then a + pointer to a GLuint. With Vulkan, the native handle is a VkImage, so \c + object is a pointer to a VkImage. With Direct3D 11 and Metal \c + object is a pointer to a ID3D11Texture2D or MTLTexture pointer, respectively. + + \note Pay attention to the fact that \a object is always a pointer + to the native texture handle type, even if the native type itself is a + pointer. + */ + +/*! + \variable QRhiTexture::NativeTexture::layout + \brief Specifies the current image layout for APIs like Vulkan. + + For Vulkan, \c layout contains a \c VkImageLayout value. + */ + /*! \internal */ @@ -2196,11 +2222,24 @@ QRhiResource::Type QRhiTexture::resourceType() const \sa QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, QRhiMetalTextureNativeHandles, QRhiGles2TextureNativeHandles */ +// TODO: remove this version once QtQuick has stopped using it const QRhiNativeHandles *QRhiTexture::nativeHandles() { return nullptr; } +/*! + \return the underlying native resources for this texture. The returned value + will be empty if exposing the underlying native resources is not supported by + the backend. + + \sa buildFrom() + */ +QRhiTexture::NativeTexture QRhiTexture::nativeTexture() +{ + return {}; +} + /*! Similar to build() except that no new native textures are created. Instead, the texture from \a src is used. @@ -2224,12 +2263,40 @@ const QRhiNativeHandles *QRhiTexture::nativeHandles() \sa QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, QRhiMetalTextureNativeHandles, QRhiGles2TextureNativeHandles */ +// TODO: remove this version once QtQuick has stopped using it bool QRhiTexture::buildFrom(const QRhiNativeHandles *src) { Q_UNUSED(src); return false; } +/*! + Similar to build() except that no new native textures are created. Instead, + the native texture resources specified by \a src is used. + + This allows importing an existing native texture object (which must belong + to the same device or sharing context, depending on the graphics API) from + an external graphics engine. + + \note format(), pixelSize(), sampleCount(), and flags() must still be set + correctly. Passing incorrect sizes and other values to QRhi::newTexture() + and then following it with a buildFrom() expecting that the native texture + object alone is sufficient to deduce such values is \b wrong and will lead + to problems. + + \note QRhiTexture does not take ownership of the texture object. release() + does not free the object or any associated memory. + + The opposite of this operation, exposing a QRhiTexture-created native + texture object to a foreign engine, is possible via nativeTexture(). + +*/ +bool QRhiTexture::buildFrom(QRhiTexture::NativeTexture src) +{ + Q_UNUSED(src); + return false; +} + /*! \class QRhiSampler \internal diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 6fb9c44ae6..44118b2f10 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -760,6 +760,11 @@ public: ASTC_12x12 }; + struct NativeTexture { + const void *object; + int layout; + }; + QRhiResource::Type resourceType() const override; Format format() const { return m_format; } @@ -776,7 +781,9 @@ public: virtual bool build() = 0; virtual const QRhiNativeHandles *nativeHandles(); + virtual NativeTexture nativeTexture(); virtual bool buildFrom(const QRhiNativeHandles *src); + virtual bool buildFrom(NativeTexture src); protected: QRhiTexture(QRhiImplementation *rhi, Format format_, const QSize &pixelSize_, diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 52109edce0..ba2488bffb 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -2764,11 +2764,39 @@ bool QD3D11Texture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) +{ + auto *srcTex = static_cast(src.object); + if (!srcTex || !*srcTex) + return false; + + if (!prepareBuild()) + return false; + + tex = *srcTex; + + if (!finishBuild()) + return false; + + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, int(mipLevelCount), m_flags.testFlag(CubeMap) ? 6 : 1, int(sampleDesc.Count))); + + owns = false; + QRHI_RES_RHI(QRhiD3D11); + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QD3D11Texture::nativeHandles() { return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QD3D11Texture::nativeTexture() +{ + return {&nativeHandlesStruct.texture, 0}; +} + ID3D11UnorderedAccessView *QD3D11Texture::unorderedAccessViewForLevel(int level) { if (perLevelViews[level]) diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index 13c56b1d6d..8f02c4300b 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -100,7 +100,9 @@ struct QD3D11Texture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; + NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); bool finishBuild(); diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index b551980bb3..563d59b318 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3404,11 +3404,40 @@ bool QGles2Texture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QGles2Texture::buildFrom(QRhiTexture::NativeTexture src) +{ + const uint *textureId = static_cast(src.object); + if (!textureId || !*textureId) + return false; + + if (!prepareBuild()) + return false; + + texture = *textureId; + specified = true; + + QRHI_RES_RHI(QRhiGles2); + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, 1)); + + owns = false; + nativeHandlesStruct.texture = texture; + + generation += 1; + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QGles2Texture::nativeHandles() { return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QGles2Texture::nativeTexture() +{ + return {&nativeHandlesStruct.texture, 0}; +} + QGles2Sampler::QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v) : QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v) diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index b0f5e340fb..0283fadb4e 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -133,7 +133,9 @@ struct QGles2Texture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; + NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index e5af1cfab1..555ed5e79f 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -2499,11 +2499,40 @@ bool QMetalTexture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src) +{ + void * const * tex = (void * const *) src.object; + if (!tex || !*tex) + return false; + + if (!prepareBuild()) + return false; + + d->tex = (id) *tex; + + d->owns = false; + nativeHandlesStruct.texture = d->tex; + + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, samples)); + + lastActiveFrameSlot = -1; + generation += 1; + QRHI_RES_RHI(QRhiMetal); + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QMetalTexture::nativeHandles() { return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QMetalTexture::nativeTexture() +{ + return {&nativeHandlesStruct.texture, 0}; +} + id QMetalTextureData::viewForLevel(int level) { Q_ASSERT(level >= 0 && level < int(q->mipLevelCount)); diff --git a/src/gui/rhi/qrhimetal_p_p.h b/src/gui/rhi/qrhimetal_p_p.h index 7876539fcd..8e655fd98b 100644 --- a/src/gui/rhi/qrhimetal_p_p.h +++ b/src/gui/rhi/qrhimetal_p_p.h @@ -101,7 +101,9 @@ struct QMetalTexture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; + NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index 0baea1b9d6..80f004e049 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -651,6 +651,12 @@ bool QNullTexture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QNullTexture::buildFrom(QRhiTexture::NativeTexture src) +{ + Q_UNUSED(src) + return buildFrom(nullptr); +} + const QRhiNativeHandles *QNullTexture::nativeHandles() { return &nativeHandlesStruct; diff --git a/src/gui/rhi/qrhinull_p_p.h b/src/gui/rhi/qrhinull_p_p.h index c96f279f7d..57c3de0418 100644 --- a/src/gui/rhi/qrhinull_p_p.h +++ b/src/gui/rhi/qrhinull_p_p.h @@ -81,6 +81,7 @@ struct QNullTexture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; QRhiNullTextureNativeHandles nativeHandlesStruct; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 49ca2326bc..21ae142b1d 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -5370,12 +5370,42 @@ bool QVkTexture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QVkTexture::buildFrom(QRhiTexture::NativeTexture src) +{ + auto *img = static_cast(src.object); + if (!img || !*img) + return false; + + if (!prepareBuild()) + return false; + + image = *img; + + if (!finishBuild()) + return false; + + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, int(mipLevelCount), m_flags.testFlag(CubeMap) ? 6 : 1, samples)); + + usageState.layout = VkImageLayout(src.layout); + + owns = false; + QRHI_RES_RHI(QRhiVulkan); + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QVkTexture::nativeHandles() { nativeHandlesStruct.layout = usageState.layout; return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QVkTexture::nativeTexture() +{ + return {&nativeHandlesStruct.image, usageState.layout}; +} + VkImageView QVkTexture::imageViewForLevel(int level) { Q_ASSERT(level >= 0 && level < int(mipLevelCount)); diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index ffa8c59ed5..d1b77870a1 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -121,7 +121,9 @@ struct QVkTexture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; + NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); bool finishBuild(); -- cgit v1.2.3 From 3359b29c99581f52acf033489ad35884a01ccac8 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 3 Dec 2019 11:13:42 +0100 Subject: QDoubleValidator: Fix thousand separator handling QDoubleValidator would accept "1,23" as valid in a locale which has ',' as a thousand separator. However, it should have been Intermediate instead, as there is still one digit missing. Fixes: QTBUG-75110 Change-Id: I6de90f0b6f1eae95dc8dfc8e5f9658e482e46db3 Reviewed-by: Ulf Hermann Reviewed-by: Edward Welbourne --- src/gui/util/qvalidator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 2237b016e9..54cbb28ffa 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -688,7 +688,7 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL return QValidator::Invalid; bool ok = false; - double i = buff.toDouble(&ok); // returns 0.0 if !ok + double i = locale.toDouble(input, &ok); // returns 0.0 if !ok if (i == qt_qnan()) return QValidator::Invalid; if (!ok) -- cgit v1.2.3 From d872719bf543a60108db88632d061e343e12b607 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 26 Nov 2018 10:18:24 +0100 Subject: Don't use QHash::unite to merge hashes QHash::unite can silently turn a regular QHash into a multi hash, something that is not intended here. Use a regular insert() instead. Change-Id: I9244a8553e84eed5367939019347b51491765ea0 Reviewed-by: Laszlo Agocs --- src/gui/util/qshadergraphloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/util/qshadergraphloader.cpp b/src/gui/util/qshadergraphloader.cpp index a393e876e0..26848020f2 100644 --- a/src/gui/util/qshadergraphloader.cpp +++ b/src/gui/util/qshadergraphloader.cpp @@ -136,7 +136,7 @@ void QShaderGraphLoader::load() if (prototypesValue.isObject()) { QShaderNodesLoader loader; loader.load(prototypesValue.toObject()); - m_prototypes.unite(loader.nodes()); + m_prototypes.insert(loader.nodes()); } else { qWarning() << "Invalid prototypes property, should be an object"; m_status = Error; -- cgit v1.2.3 From 81459dd9c05f057981ddf2db0c2302030a73cb01 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 4 Dec 2019 10:57:08 +0100 Subject: Copy formatting attributes when cloning an empty QTextDocument When cloning a QTextDocument, the text fragment of the original document is copied into the new one, which results into copying also the formatting attributes. However, when the text document is empty, the corresponding text fragment is also empty, so nothing is copied. If we want to transfer the formatting attributes for an empty document, we need to set them explicitly. Fixes: QTBUG-80399 Change-Id: I382cd0821723436120af47c06ec7bfa849636307 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Eirik Aavitsland --- src/gui/text/qtextdocument.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index e94f635651..4b35509ace 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -347,7 +347,19 @@ QTextDocument *QTextDocument::clone(QObject *parent) const { Q_D(const QTextDocument); QTextDocument *doc = new QTextDocument(parent); - QTextCursor(doc).insertFragment(QTextDocumentFragment(this)); + if (isEmpty()) { + const QTextCursor thisCursor(const_cast(this)); + + const auto blockFormat = thisCursor.blockFormat(); + if (blockFormat.isValid() && !blockFormat.isEmpty()) + QTextCursor(doc).setBlockFormat(blockFormat); + + const auto blockCharFormat = thisCursor.blockCharFormat(); + if (blockCharFormat.isValid() && !blockCharFormat.isEmpty()) + QTextCursor(doc).setBlockCharFormat(blockCharFormat); + } else { + QTextCursor(doc).insertFragment(QTextDocumentFragment(this)); + } doc->rootFrame()->setFrameFormat(rootFrame()->frameFormat()); QTextDocumentPrivate *priv = doc->d_func(); priv->title = d->title; -- cgit v1.2.3 From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/accessible/qaccessible.cpp | 20 ++-- src/gui/accessible/qaccessibleobject.cpp | 10 +- src/gui/accessible/qplatformaccessibility.cpp | 2 +- src/gui/animation/qguivariantanimation.cpp | 10 +- src/gui/image/qbmphandler.cpp | 4 +- src/gui/image/qicon.cpp | 16 ++-- src/gui/image/qiconloader.cpp | 2 +- src/gui/image/qimage.cpp | 46 ++++----- src/gui/image/qimage_conversions.cpp | 8 +- src/gui/image/qimageiohandler.cpp | 2 +- src/gui/image/qimagereader.cpp | 12 +-- src/gui/image/qimagereaderwriterhelpers.cpp | 6 +- src/gui/image/qimagewriter.cpp | 14 +-- src/gui/image/qmovie.cpp | 2 +- src/gui/image/qpaintengine_pic.cpp | 6 +- src/gui/image/qpicture.cpp | 22 ++--- src/gui/image/qpixmap.cpp | 6 +- src/gui/image/qpixmap_blitter.cpp | 8 +- src/gui/image/qpixmapcache.cpp | 14 +-- src/gui/image/qplatformpixmap.cpp | 2 +- src/gui/image/qpnghandler.cpp | 58 +++++------ src/gui/image/qxpmhandler.cpp | 4 +- src/gui/itemmodels/qstandarditemmodel.cpp | 92 +++++++++--------- src/gui/kernel/qclipboard.cpp | 6 +- src/gui/kernel/qcursor.cpp | 14 +-- src/gui/kernel/qdnd.cpp | 12 +-- src/gui/kernel/qdrag.cpp | 6 +- src/gui/kernel/qevent.cpp | 8 +- src/gui/kernel/qguiapplication.cpp | 106 ++++++++++----------- src/gui/kernel/qguivariant.cpp | 16 ++-- src/gui/kernel/qkeymapper.cpp | 2 +- src/gui/kernel/qoffscreensurface.cpp | 14 +-- src/gui/kernel/qopenglcontext.cpp | 56 +++++------ src/gui/kernel/qopenglwindow.cpp | 6 +- src/gui/kernel/qpaintdevicewindow.cpp | 2 +- src/gui/kernel/qpalette.cpp | 2 +- src/gui/kernel/qplatformclipboard.cpp | 2 +- src/gui/kernel/qplatformcursor.cpp | 10 +- src/gui/kernel/qplatforminputcontextfactory.cpp | 2 +- src/gui/kernel/qplatformintegration.cpp | 22 ++--- src/gui/kernel/qplatformintegrationplugin.cpp | 2 +- src/gui/kernel/qplatformnativeinterface.cpp | 20 ++-- src/gui/kernel/qplatformopenglcontext.cpp | 2 +- src/gui/kernel/qplatformscreen.cpp | 8 +- src/gui/kernel/qplatformtheme.cpp | 16 ++-- src/gui/kernel/qscreen.cpp | 2 +- src/gui/kernel/qsessionmanager.cpp | 2 +- src/gui/kernel/qshortcutmap.cpp | 12 +-- src/gui/kernel/qsimpledrag.cpp | 2 +- src/gui/kernel/qstylehints.cpp | 2 +- src/gui/kernel/qsurface.cpp | 2 +- src/gui/kernel/qwindow.cpp | 18 ++-- src/gui/kernel/qwindowsysteminterface.cpp | 2 +- src/gui/opengl/qopengl.cpp | 2 +- src/gui/opengl/qopenglbuffer.cpp | 10 +- src/gui/opengl/qopenglcustomshaderstage.cpp | 8 +- src/gui/opengl/qopengldebug.cpp | 24 ++--- src/gui/opengl/qopenglengineshadermanager.cpp | 20 ++-- src/gui/opengl/qopenglframebufferobject.cpp | 12 +-- src/gui/opengl/qopenglfunctions.cpp | 6 +- src/gui/opengl/qopenglfunctions_1_0.cpp | 6 +- src/gui/opengl/qopenglfunctions_1_1.cpp | 10 +- src/gui/opengl/qopenglfunctions_1_2.cpp | 14 +-- src/gui/opengl/qopenglfunctions_1_3.cpp | 18 ++-- src/gui/opengl/qopenglfunctions_1_4.cpp | 22 ++--- src/gui/opengl/qopenglfunctions_1_5.cpp | 24 ++--- src/gui/opengl/qopenglfunctions_2_0.cpp | 26 ++--- src/gui/opengl/qopenglfunctions_2_1.cpp | 28 +++--- src/gui/opengl/qopenglfunctions_3_0.cpp | 30 +++--- src/gui/opengl/qopenglfunctions_3_1.cpp | 22 ++--- .../opengl/qopenglfunctions_3_2_compatibility.cpp | 34 +++---- src/gui/opengl/qopenglfunctions_3_2_core.cpp | 24 ++--- .../opengl/qopenglfunctions_3_3_compatibility.cpp | 38 ++++---- src/gui/opengl/qopenglfunctions_3_3_core.cpp | 26 ++--- .../opengl/qopenglfunctions_4_0_compatibility.cpp | 40 ++++---- src/gui/opengl/qopenglfunctions_4_0_core.cpp | 28 +++--- .../opengl/qopenglfunctions_4_1_compatibility.cpp | 42 ++++---- src/gui/opengl/qopenglfunctions_4_1_core.cpp | 30 +++--- .../opengl/qopenglfunctions_4_2_compatibility.cpp | 44 ++++----- src/gui/opengl/qopenglfunctions_4_2_core.cpp | 32 +++---- .../opengl/qopenglfunctions_4_3_compatibility.cpp | 46 ++++----- src/gui/opengl/qopenglfunctions_4_3_core.cpp | 34 +++---- .../opengl/qopenglfunctions_4_4_compatibility.cpp | 48 +++++----- src/gui/opengl/qopenglfunctions_4_4_core.cpp | 36 +++---- .../opengl/qopenglfunctions_4_5_compatibility.cpp | 52 +++++----- src/gui/opengl/qopenglfunctions_4_5_core.cpp | 38 ++++---- src/gui/opengl/qopenglpaintdevice.cpp | 2 +- src/gui/opengl/qopenglpaintengine.cpp | 20 ++-- src/gui/opengl/qopenglshaderprogram.cpp | 12 +-- src/gui/opengl/qopengltexture.cpp | 32 +++---- src/gui/opengl/qopengltextureglyphcache.cpp | 34 +++---- src/gui/opengl/qopengltimerquery.cpp | 26 ++--- src/gui/opengl/qopenglversionfunctions.cpp | 2 +- src/gui/opengl/qopenglversionfunctionsfactory.cpp | 2 +- src/gui/opengl/qopenglvertexarrayobject.cpp | 16 ++-- src/gui/painting/qblittable.cpp | 2 +- src/gui/painting/qbrush.cpp | 14 +-- src/gui/painting/qcosmeticstroker.cpp | 6 +- src/gui/painting/qdrawhelper.cpp | 92 +++++++++--------- src/gui/painting/qemulationpaintengine.cpp | 2 +- src/gui/painting/qimagescale.cpp | 4 +- src/gui/painting/qmemrotate.cpp | 6 +- src/gui/painting/qoutlinemapper.cpp | 2 +- src/gui/painting/qpagesize.cpp | 20 ++-- src/gui/painting/qpaintdevice.cpp | 6 +- src/gui/painting/qpaintengine.cpp | 12 +-- src/gui/painting/qpaintengine_raster.cpp | 96 +++++++++---------- src/gui/painting/qpaintengineex.cpp | 30 +++--- src/gui/painting/qpainter.cpp | 54 +++++------ src/gui/painting/qpainterpath.cpp | 6 +- src/gui/painting/qpathclipper.cpp | 10 +- src/gui/painting/qpathsimplifier.cpp | 42 ++++---- src/gui/painting/qpdf.cpp | 18 ++-- src/gui/painting/qpdfwriter.cpp | 2 +- src/gui/painting/qpen.cpp | 2 +- src/gui/painting/qplatformbackingstore.cpp | 4 +- src/gui/painting/qrasterizer.cpp | 4 +- src/gui/painting/qregion.cpp | 74 +++++++------- src/gui/painting/qstroker.cpp | 10 +- src/gui/painting/qtextureglyphcache.cpp | 2 +- src/gui/painting/qtriangulatingstroker.cpp | 4 +- src/gui/painting/qtriangulator.cpp | 28 +++--- src/gui/text/qabstracttextdocumentlayout.cpp | 2 +- src/gui/text/qdistancefield.cpp | 8 +- src/gui/text/qfont.cpp | 74 +++++++------- src/gui/text/qfontdatabase.cpp | 50 +++++----- src/gui/text/qfontengine.cpp | 40 ++++---- src/gui/text/qfontengine_qpf2.cpp | 8 +- src/gui/text/qfontmetrics.cpp | 82 ++++++++-------- src/gui/text/qplatformfontdatabase.cpp | 2 +- src/gui/text/qrawfont.cpp | 6 +- src/gui/text/qstatictext.cpp | 4 +- src/gui/text/qsyntaxhighlighter.cpp | 4 +- src/gui/text/qtextcursor.cpp | 26 ++--- src/gui/text/qtextdocument.cpp | 6 +- src/gui/text/qtextdocument_p.cpp | 18 ++-- src/gui/text/qtextdocumentfragment.cpp | 16 ++-- src/gui/text/qtextdocumentlayout.cpp | 24 ++--- src/gui/text/qtextdocumentwriter.cpp | 6 +- src/gui/text/qtextengine.cpp | 44 ++++----- src/gui/text/qtexthtmlparser.cpp | 6 +- src/gui/text/qtextimagehandler.cpp | 2 +- src/gui/text/qtextlayout.cpp | 8 +- src/gui/text/qtextobject.cpp | 16 ++-- src/gui/text/qtextodfwriter.cpp | 12 +-- src/gui/text/qtextoption.cpp | 8 +- src/gui/text/qzip.cpp | 16 ++-- src/gui/util/qdesktopservices.cpp | 2 +- src/gui/util/qgridlayoutengine.cpp | 26 ++--- src/gui/util/qtexturefiledata.cpp | 2 +- src/gui/vulkan/qvulkaninstance.cpp | 2 +- src/gui/vulkan/qvulkanwindow.cpp | 2 +- 152 files changed, 1418 insertions(+), 1418 deletions(-) (limited to 'src/gui') diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index db47a3abc1..7922d6fb06 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -478,15 +478,15 @@ Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins) Q_GLOBAL_STATIC(QList, qAccessibleFactories) Q_GLOBAL_STATIC(QList, qAccessibleActivationObservers) -QAccessible::UpdateHandler QAccessible::updateHandler = 0; -QAccessible::RootObjectHandler QAccessible::rootObjectHandler = 0; +QAccessible::UpdateHandler QAccessible::updateHandler = nullptr; +QAccessible::RootObjectHandler QAccessible::rootObjectHandler = nullptr; static bool cleanupAdded = false; static QPlatformAccessibility *platformAccessibility() { QPlatformIntegration *pfIntegration = QGuiApplicationPrivate::platformIntegration(); - return pfIntegration ? pfIntegration->accessibility() : 0; + return pfIntegration ? pfIntegration->accessibility() : nullptr; } /*! @@ -673,7 +673,7 @@ void QAccessible::removeActivationObserver(ActivationObserver *observer) QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) { if (!object) - return 0; + return nullptr; if (Id id = QAccessibleCache::instance()->objectToId.value(object)) return QAccessibleCache::instance()->interfaceForId(id); @@ -696,7 +696,7 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) // Find a QAccessiblePlugin (factory) for the class name. If there's // no entry in the cache try to create it using the plugin loader. if (!qAccessiblePlugins()->contains(cn)) { - QAccessiblePlugin *factory = 0; // 0 means "no plugin found". This is cached as well. + QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well. const int index = loader()->indexOf(cn); if (index != -1) factory = qobject_cast(loader()->instance(index)); @@ -724,7 +724,7 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) return appInterface; } - return 0; + return nullptr; } /*! @@ -1113,7 +1113,7 @@ QAccessibleInterface::relations(QAccessible::Relation /*match = QAccessible::All */ QAccessibleInterface *QAccessibleInterface::focusChild() const { - return 0; + return nullptr; } /*! @@ -1758,12 +1758,12 @@ QAccessibleTextSelectionEvent::~QAccessibleTextSelectionEvent() */ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const { - if (m_object == 0) + if (m_object == nullptr) return QAccessible::accessibleInterface(m_uniqueId); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object); if (!iface || !iface->isValid()) - return 0; + return nullptr; if (m_child >= 0) { QAccessibleInterface *child = iface->child(m_child); @@ -1791,7 +1791,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const */ QWindow *QAccessibleInterface::window() const { - return 0; + return nullptr; } /*! diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index 2ef8502ad5..771cfda574 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -128,7 +128,7 @@ QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const if (childIface->isValid() && childIface->rect().contains(x,y)) return childIface; } - return 0; + return nullptr; } /*! @@ -152,7 +152,7 @@ QWindow *QAccessibleApplication::window() const { // an application can have several windows, and AFAIK we don't need // to notify about changes on the application. - return 0; + return nullptr; } // all toplevel windows except popups and the desktop @@ -190,7 +190,7 @@ int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) cons QAccessibleInterface *QAccessibleApplication::parent() const { - return 0; + return nullptr; } QAccessibleInterface *QAccessibleApplication::child(int index) const @@ -198,7 +198,7 @@ QAccessibleInterface *QAccessibleApplication::child(int index) const const QObjectList tlo(topLevelObjects()); if (index >= 0 && index < tlo.count()) return QAccessible::queryAccessibleInterface(tlo.at(index)); - return 0; + return nullptr; } @@ -207,7 +207,7 @@ QAccessibleInterface *QAccessibleApplication::focusChild() const { if (QWindow *window = QGuiApplication::focusWindow()) return window->accessibleRoot(); - return 0; + return nullptr; } /*! \reimp */ diff --git a/src/gui/accessible/qplatformaccessibility.cpp b/src/gui/accessible/qplatformaccessibility.cpp index 8c806d47b8..4813b83963 100644 --- a/src/gui/accessible/qplatformaccessibility.cpp +++ b/src/gui/accessible/qplatformaccessibility.cpp @@ -114,7 +114,7 @@ void QPlatformAccessibility::initialize() typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; const PluginKeyMap keyMap = bridgeloader()->keyMap(); - QAccessibleBridgePlugin *factory = 0; + QAccessibleBridgePlugin *factory = nullptr; int i = -1; const PluginKeyMapConstIterator cend = keyMap.constEnd(); for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp index a5b6d8b95c..8afe77ed46 100644 --- a/src/gui/animation/qguivariantanimation.cpp +++ b/src/gui/animation/qguivariantanimation.cpp @@ -75,15 +75,15 @@ static void qUnregisterGuiGetInterpolator() { // casts required by Sun CC 5.5 qRegisterAnimationInterpolator( - (QVariant (*)(const QColor &, const QColor &, qreal))0); + (QVariant (*)(const QColor &, const QColor &, qreal))nullptr); qRegisterAnimationInterpolator( - (QVariant (*)(const QVector2D &, const QVector2D &, qreal))0); + (QVariant (*)(const QVector2D &, const QVector2D &, qreal))nullptr); qRegisterAnimationInterpolator( - (QVariant (*)(const QVector3D &, const QVector3D &, qreal))0); + (QVariant (*)(const QVector3D &, const QVector3D &, qreal))nullptr); qRegisterAnimationInterpolator( - (QVariant (*)(const QVector4D &, const QVector4D &, qreal))0); + (QVariant (*)(const QVector4D &, const QVector4D &, qreal))nullptr); qRegisterAnimationInterpolator( - (QVariant (*)(const QQuaternion &, const QQuaternion &, qreal))0); + (QVariant (*)(const QQuaternion &, const QQuaternion &, qreal))nullptr); } Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator) diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 7f8e072322..32b6131309 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -414,7 +414,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset, *p++ = tmp >> 4; } if ((((c & 3) + 1) & 2) == 2) - d->getChar(0); // align on word boundary + d->getChar(nullptr); // align on word boundary x += c; } } else { // encoded mode @@ -494,7 +494,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset, if (d->read((char *)p, b) != b) return false; if ((b & 1) == 1) - d->getChar(0); // align on word boundary + d->getChar(nullptr); // align on word boundary x += b; p += b; } diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 84e387e317..19be066d23 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -132,7 +132,7 @@ static void qt_cleanup_icon_cache() if Qt::AA_UseHighDpiPixmaps is not set this function returns 1.0 to keep non-hihdpi aware code working. */ -static qreal qt_effective_device_pixel_ratio(QWindow *window = 0) +static qreal qt_effective_device_pixel_ratio(QWindow *window = nullptr) { if (!qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) return qreal(1.0); @@ -228,7 +228,7 @@ static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngi QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state) { - QPixmapIconEngineEntry *pe = 0; + QPixmapIconEngineEntry *pe = nullptr; for (int i = 0; i < pixmaps.count(); ++i) if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) { if (pe) @@ -674,7 +674,7 @@ QFactoryLoader *qt_iconEngineFactoryLoader() Constructs a null icon. */ QIcon::QIcon() noexcept - : d(0) + : d(nullptr) { } @@ -682,7 +682,7 @@ QIcon::QIcon() noexcept Constructs an icon from a \a pixmap. */ QIcon::QIcon(const QPixmap &pixmap) - :d(0) + :d(nullptr) { addPixmap(pixmap); } @@ -723,7 +723,7 @@ QIcon::QIcon(const QIcon &other) complete list of the supported file formats. */ QIcon::QIcon(const QString &fileName) - : d(0) + : d(nullptr) { addFile(fileName); } @@ -838,7 +838,7 @@ QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const { if (!d) return QPixmap(); - return pixmap(0, size, mode, state); + return pixmap(nullptr, size, mode, state); } /*! @@ -878,7 +878,7 @@ QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const { if (!d) return QSize(); - return actualSize(0, size, mode, state); + return actualSize(nullptr, size, mode, state); } /*! @@ -1008,7 +1008,7 @@ void QIcon::detach() if (d->engine->isNull()) { if (!d->ref.deref()) delete d; - d = 0; + d = nullptr; return; } else if (d->ref.loadRelaxed() != 1) { QIconPrivate *x = new QIconPrivate(d->engine->clone()); diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 27c82bc09f..e67b387981 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -714,7 +714,7 @@ QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QThemeIconInfo &in // Find the minimum distance icon int minimalSize = INT_MAX; - QIconLoaderEngineEntry *closestMatch = 0; + QIconLoaderEngineEntry *closestMatch = nullptr; for (int i = 0; i < numEntries; ++i) { QIconLoaderEngineEntry *entry = info.entries.at(i); int distance = directorySizeDistance(entry->dir, iconsize, scale); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 869e206524..99d64737c5 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE static inline bool isLocked(QImageData *data) { - return data != 0 && data->is_locked; + return data != nullptr && data->is_locked; } #if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001) @@ -99,15 +99,15 @@ static int next_qimage_serial_number() } QImageData::QImageData() - : ref(0), width(0), height(0), depth(0), nbytes(0), devicePixelRatio(1.0), data(0), + : ref(0), width(0), height(0), depth(0), nbytes(0), devicePixelRatio(1.0), data(nullptr), format(QImage::Format_ARGB32), bytes_per_line(0), ser_no(next_qimage_serial_number()), detach_no(0), dpmx(qt_defaultDpiX() * 100 / qreal(2.54)), dpmy(qt_defaultDpiY() * 100 / qreal(2.54)), offset(0, 0), own_data(true), ro_data(false), has_alpha_clut(false), - is_cached(false), is_locked(false), cleanupFunction(0), cleanupInfo(0), - paintEngine(0) + is_cached(false), is_locked(false), cleanupFunction(nullptr), cleanupInfo(nullptr), + paintEngine(nullptr) { } @@ -170,7 +170,7 @@ QImageData::~QImageData() delete paintEngine; if (data && own_data) free(data); - data = 0; + data = nullptr; } #if defined(_M_ARM) @@ -746,7 +746,7 @@ bool QImageData::checkForAlphaPixels() const QImage::QImage() noexcept : QPaintDevice() { - d = 0; + d = nullptr; } /*! @@ -955,7 +955,7 @@ QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, Forma QImage::QImage(const QString &fileName, const char *format) : QPaintDevice() { - d = 0; + d = nullptr; load(fileName, format); } @@ -981,10 +981,10 @@ extern bool qt_read_xpm_image_or_array(QIODevice *device, const char * const *so QImage::QImage(const char * const xpm[]) : QPaintDevice() { - d = 0; + d = nullptr; if (!xpm) return; - if (!qt_read_xpm_image_or_array(0, xpm, *this)) + if (!qt_read_xpm_image_or_array(nullptr, xpm, *this)) // Issue: Warning because the constructor may be ambigious qWarning("QImage::QImage(), XPM is not supported"); } @@ -1003,7 +1003,7 @@ QImage::QImage(const QImage &image) : QPaintDevice() { if (image.paintingActive() || isLocked(image.d)) { - d = 0; + d = nullptr; image.copy().swap(*this); } else { d = image.d; @@ -1593,13 +1593,13 @@ void QImage::setColor(int i, QRgb c) uchar *QImage::scanLine(int i) { if (!d) - return 0; + return nullptr; detach(); // In case detach() ran out of memory if (!d) - return 0; + return nullptr; return d->data + i * d->bytes_per_line; } @@ -1610,7 +1610,7 @@ uchar *QImage::scanLine(int i) const uchar *QImage::scanLine(int i) const { if (!d) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < height()); return d->data + i * d->bytes_per_line; @@ -1633,7 +1633,7 @@ const uchar *QImage::scanLine(int i) const const uchar *QImage::constScanLine(int i) const { if (!d) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < height()); return d->data + i * d->bytes_per_line; @@ -1653,12 +1653,12 @@ const uchar *QImage::constScanLine(int i) const uchar *QImage::bits() { if (!d) - return 0; + return nullptr; detach(); // In case detach ran out of memory... if (!d) - return 0; + return nullptr; return d->data; } @@ -1672,7 +1672,7 @@ uchar *QImage::bits() */ const uchar *QImage::bits() const { - return d ? d->data : 0; + return d ? d->data : nullptr; } @@ -1688,7 +1688,7 @@ const uchar *QImage::bits() const */ const uchar *QImage::constBits() const { - return d ? d->data : 0; + return d ? d->data : nullptr; } /*! @@ -3027,11 +3027,11 @@ QImage QImage::createHeuristicMask(bool clipTight) const while(!done) { done = true; ypn = m.scanLine(0); - ypc = 0; + ypc = nullptr; for (y = 0; y < h; y++) { ypp = ypc; ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); + ypn = (y == h-1) ? nullptr : m.scanLine(y+1); const QRgb *p = (const QRgb *)scanLine(y); for (x = 0; x < w; x++) { // slowness here - it's possible to do six of these tests @@ -3053,11 +3053,11 @@ QImage QImage::createHeuristicMask(bool clipTight) const if (!clipTight) { ypn = m.scanLine(0); - ypc = 0; + ypc = nullptr; for (y = 0; y < h; y++) { ypp = ypc; ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); + ypn = (y == h-1) ? nullptr : m.scanLine(y+1); const QRgb *p = (const QRgb *)scanLine(y); for (x = 0; x < w; x++) { if ((*p & 0x00ffffff) != background) { @@ -4122,7 +4122,7 @@ void QImage::setText(const QString &key, const QString &value) QPaintEngine *QImage::paintEngine() const { if (!d) - return 0; + return nullptr; if (!d->paintEngine) { QPaintDevice *paintDevice = const_cast(this); diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 8f33a13b95..27088698ec 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -198,7 +198,7 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio store = destLayout->storeFromRGB32; } QDitherInfo dither; - QDitherInfo *ditherPtr = 0; + QDitherInfo *ditherPtr = nullptr; if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither) ditherPtr = &dither; @@ -212,8 +212,8 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio buffer = reinterpret_cast(destData) + x; else l = qMin(l, BufferSize); - const uint *ptr = fetch(buffer, srcData, x, l, 0, ditherPtr); - store(destData, ptr, x, l, 0, ditherPtr); + const uint *ptr = fetch(buffer, srcData, x, l, nullptr, ditherPtr); + store(destData, ptr, x, l, nullptr, ditherPtr); x += l; } srcData += src->bytes_per_line; @@ -314,7 +314,7 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im store = destLayout->storeFromRGB32; } QDitherInfo dither; - QDitherInfo *ditherPtr = 0; + QDitherInfo *ditherPtr = nullptr; if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither) ditherPtr = &dither; diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp index a4f927a462..0c9083a16e 100644 --- a/src/gui/image/qimageiohandler.cpp +++ b/src/gui/image/qimageiohandler.cpp @@ -288,7 +288,7 @@ public: QImageIOHandlerPrivate::QImageIOHandlerPrivate(QImageIOHandler *q) { - device = 0; + device = nullptr; q_ptr = q; } diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index dff24b449a..5e3b608d20 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -179,10 +179,10 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, bool ignoresFormatAndExtension) { if (!autoDetectImageFormat && format.isEmpty()) - return 0; + return nullptr; QByteArray form = format.toLower(); - QImageIOHandler *handler = 0; + QImageIOHandler *handler = nullptr; QByteArray suffix; #ifndef QT_NO_IMAGEFORMATPLUGIN @@ -450,7 +450,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, qDebug("QImageReader::createReadHandler: no handlers found. giving up."); #endif // no handler: give up. - return 0; + return nullptr; } handler->setDevice(device); @@ -500,9 +500,9 @@ public: QImageReaderPrivate::QImageReaderPrivate(QImageReader *qq) : autoDetectImageFormat(true), ignoresFormatAndExtension(false) { - device = 0; + device = nullptr; deleteDevice = false; - handler = 0; + handler = nullptr; quality = -1; imageReaderError = QImageReader::UnknownError; autoTransform = UsePluginDefault; @@ -571,7 +571,7 @@ bool QImageReaderPrivate::initHandler() } // assign a handler - if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == 0) { + if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == nullptr) { imageReaderError = QImageReader::UnsupportedFormatError; errorString = QImageReader::tr("Unsupported image format"); return false; diff --git a/src/gui/image/qimagereaderwriterhelpers.cpp b/src/gui/image/qimagereaderwriterhelpers.cpp index a5b7fb6449..dd56d887a7 100644 --- a/src/gui/image/qimagereaderwriterhelpers.cpp +++ b/src/gui/image/qimagereaderwriterhelpers.cpp @@ -63,7 +63,7 @@ static void appendImagePluginFormats(QFactoryLoader *loader, const PluginKeyMap keyMap = loader->keyMap(); const PluginKeyMapConstIterator cend = keyMap.constEnd(); int i = -1; - QImageIOPlugin *plugin = 0; + QImageIOPlugin *plugin = nullptr; result->reserve(result->size() + keyMap.size()); for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { if (it.key() != i) { @@ -71,7 +71,7 @@ static void appendImagePluginFormats(QFactoryLoader *loader, plugin = qobject_cast(loader->instance(i)); } const QByteArray key = it.value().toLatin1(); - if (plugin && (plugin->capabilities(0, key) & cap) != 0) + if (plugin && (plugin->capabilities(nullptr, key) & cap) != 0) result->append(key); } } @@ -92,7 +92,7 @@ static void appendImagePluginMimeTypes(QFactoryLoader *loader, const int keyCount = keys.size(); for (int k = 0; k < keyCount; ++k) { const QByteArray key = keys.at(k).toString().toLatin1(); - if (plugin && (plugin->capabilities(0, key) & cap) != 0) { + if (plugin && (plugin->capabilities(nullptr, key) & cap) != 0) { result->append(mimeTypes.at(k).toString().toLatin1()); if (resultKeys) resultKeys->append(key); diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index ec66588ddf..9dcc955fe2 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -139,7 +139,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, { QByteArray form = format.toLower(); QByteArray suffix; - QImageIOHandler *handler = 0; + QImageIOHandler *handler = nullptr; #ifndef QT_NO_IMAGEFORMATPLUGIN typedef QMultiMap PluginKeyMap; @@ -226,7 +226,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, #endif // QT_NO_IMAGEFORMATPLUGIN if (!handler) - return 0; + return nullptr; handler->setDevice(device); if (!testFormat.isEmpty()) @@ -270,9 +270,9 @@ public: */ QImageWriterPrivate::QImageWriterPrivate(QImageWriter *qq) { - device = 0; + device = nullptr; deleteDevice = false; - handler = 0; + handler = nullptr; quality = -1; compression = -1; gamma = 0.0; @@ -304,7 +304,7 @@ bool QImageWriterPrivate::canWriteHelper() errorString = QImageWriter::tr("Device not writable"); return false; } - if (!handler && (handler = createWriteHandlerHelper(device, format)) == 0) { + if (!handler && (handler = createWriteHandlerHelper(device, format)) == nullptr) { imageWriterError = QImageWriter::UnsupportedFormatError; errorString = QImageWriter::tr("Unsupported image format"); return false; @@ -403,7 +403,7 @@ void QImageWriter::setDevice(QIODevice *device) d->device = device; d->deleteDevice = false; delete d->handler; - d->handler = 0; + d->handler = nullptr; } /*! @@ -823,7 +823,7 @@ QString QImageWriter::errorString() const */ bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const { - if (!d->handler && (d->handler = createWriteHandlerHelper(d->device, d->format)) == 0) { + if (!d->handler && (d->handler = createWriteHandlerHelper(d->device, d->format)) == nullptr) { d->imageWriterError = QImageWriter::UnsupportedFormatError; d->errorString = QImageWriter::tr("Unsupported image format"); return false; diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 25fce050a1..79019d0fdf 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -272,7 +272,7 @@ public: /*! \internal */ QMoviePrivate::QMoviePrivate(QMovie *qq) - : reader(0), speed(100), movieState(QMovie::NotRunning), + : reader(nullptr), speed(100), movieState(QMovie::NotRunning), currentFrameNumber(-1), nextFrameNumber(0), greatestFrameNumber(-1), nextDelay(0), playCounter(-1), cacheMode(QMovie::CacheNone), haveReadAll(false), isFirstIteration(true) diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp index 6a87a01a87..e89cac452a 100644 --- a/src/gui/image/qpaintengine_pic.cpp +++ b/src/gui/image/qpaintengine_pic.cpp @@ -73,14 +73,14 @@ QPicturePaintEngine::QPicturePaintEngine() : QPaintEngine(*(new QPicturePaintEnginePrivate), AllFeatures) { Q_D(QPicturePaintEngine); - d->pt = 0; + d->pt = nullptr; } QPicturePaintEngine::QPicturePaintEngine(QPaintEnginePrivate &dptr) : QPaintEngine(dptr, AllFeatures) { Q_D(QPicturePaintEngine); - d->pt = 0; + d->pt = nullptr; } QPicturePaintEngine::~QPicturePaintEngine() @@ -484,7 +484,7 @@ void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti) #endif const QTextItemInt &si = static_cast(ti); - if (si.chars == 0) + if (si.chars == nullptr) QPaintEngine::drawTextItem(p, ti); // Draw as path if (d->pic_d->formatMajor >= 9) { diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 978a07b9f9..3a32cc7f15 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -458,7 +458,7 @@ public: QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); } void setDpiX(int dpi) { dpi_x = dpi; } void setDpiY(int dpi) { dpi_y = dpi; } - QPaintEngine *paintEngine() const override { return 0; } + QPaintEngine *paintEngine() const override { return nullptr; } int metric(PaintDeviceMetric m) const override { switch(m) { @@ -709,11 +709,11 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords) QFontMetrics fm(fnt); QPointF pt(p.x(), p.y() - fm.ascent()); - qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/0, - str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); + qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/nullptr, + str, /*brect=*/nullptr, /*tabstops=*/0, /*...*/nullptr, /*tabarraylen=*/0, painter); } else { - qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/0, - str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); + qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/nullptr, + str, /*brect=*/nullptr, /*tabstops=*/0, /*...*/nullptr, /*tabarraylen=*/0, painter); } break; @@ -1369,11 +1369,11 @@ QPictureIO::QPictureIO(const QString &fileName, const char* format) void QPictureIO::init() { d = new QPictureIOData(); - d->parameters = 0; + d->parameters = nullptr; d->quality = -1; // default quality of the current format d->gamma=0.0f; d->iostat = 0; - d->iodev = 0; + d->iodev = nullptr; } /*! @@ -1467,7 +1467,7 @@ static QPictureHandler *get_picture_handler(const char *format) return list->at(i); } } - return 0; // no such handler + return nullptr; // no such handler } @@ -1887,7 +1887,7 @@ bool QPictureIO::read() if (picture_format.isEmpty()) { if (file.isOpen()) { // unknown format file.close(); - d->iodev = 0; + d->iodev = nullptr; } return false; } @@ -1913,7 +1913,7 @@ bool QPictureIO::read() if (file.isOpen()) { // picture was read using file file.close(); - d->iodev = 0; + d->iodev = nullptr; } return d->iostat == 0; // picture successfully read? } @@ -1957,7 +1957,7 @@ bool QPictureIO::write() (*h->write_picture)(this); if (file.isOpen()) { // picture was written using file file.close(); - d->iodev = 0; + d->iodev = nullptr; } return d->iostat == 0; // picture successfully written? } diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index b6e41f16a5..3fce64cb20 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -94,7 +94,7 @@ void QPixmap::doInit(int w, int h, int type) if ((w > 0 && h > 0) || type == QPlatformPixmap::BitmapType) data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type); else - data = 0; + data = nullptr; } /*! @@ -780,7 +780,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) { - if (len == 0 || buf == 0) { + if (len == 0 || buf == nullptr) { data.reset(); return false; } @@ -1455,7 +1455,7 @@ int QPixmap::metric(PaintDeviceMetric metric) const */ QPaintEngine *QPixmap::paintEngine() const { - return data ? data->paintEngine() : 0; + return data ? data->paintEngine() : nullptr; } /*! diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 649a25250c..aeed1e3b34 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -92,8 +92,8 @@ void QBlittablePlatformPixmap::setBlittable(QBlittable *blittable) void QBlittablePlatformPixmap::resize(int width, int height) { - m_blittable.reset(0); - m_engine.reset(0); + m_blittable.reset(nullptr); + m_engine.reset(nullptr); d = QGuiApplication::primaryScreen()->depth(); w = width; h = height; @@ -145,8 +145,8 @@ void QBlittablePlatformPixmap::fill(const QColor &color) // if we could just change the format, e.g. when going from // RGB32 -> ARGB8888. if (color.alpha() != 255 && !hasAlphaChannel()) { - m_blittable.reset(0); - m_engine.reset(0); + m_blittable.reset(nullptr); + m_engine.reset(nullptr); m_alpha = true; } diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 483d6d79a2..9709df9e0c 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -126,7 +126,7 @@ static inline bool qt_pixmapcache_thread_test() /*! Constructs an empty Key object. */ -QPixmapCache::Key::Key() : d(0) +QPixmapCache::Key::Key() : d(nullptr) { } @@ -259,9 +259,9 @@ uint qHash(const QPixmapCache::Key &k) } QPMCache::QPMCache() - : QObject(0), + : QObject(nullptr), QCache(cache_limit_default), - keyArray(0), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) + keyArray(nullptr), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) { } QPMCache::~QPMCache() @@ -325,7 +325,7 @@ QPixmap *QPMCache::object(const QString &key) const QPixmapCache::Key cacheKey = cacheKeys.value(key); if (!cacheKey.d || !cacheKey.d->isValid) { const_cast(this)->cacheKeys.remove(key); - return 0; + return nullptr; } QPixmap *ptr = QCache::object(cacheKey); //We didn't find the pixmap in the cache, the key is not valid anymore @@ -453,7 +453,7 @@ void QPMCache::releaseKey(const QPixmapCache::Key &key) void QPMCache::clear() { free(keyArray); - keyArray = 0; + keyArray = nullptr; freeKey = 0; keyArraySize = 0; //Mark all keys as invalid @@ -539,7 +539,7 @@ bool QPixmapCache::find(const QString &key, QPixmap *pixmap) QPixmap *ptr = pm_cache()->object(key); if (ptr && pixmap) *pixmap = *ptr; - return ptr != 0; + return ptr != nullptr; } /*! @@ -561,7 +561,7 @@ bool QPixmapCache::find(const Key &key, QPixmap *pixmap) QPixmap *ptr = pm_cache()->object(key); if (ptr && pixmap) *pixmap = *ptr; - return ptr != 0; + return ptr != nullptr; } /*! diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp index a2e01147c4..493f55514e 100644 --- a/src/gui/image/qplatformpixmap.cpp +++ b/src/gui/image/qplatformpixmap.cpp @@ -266,7 +266,7 @@ QImage QPlatformPixmap::toImage(const QRect &rect) const QImage* QPlatformPixmap::buffer() { - return 0; + return nullptr; } diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index d6caf6773a..251f09fe52 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -109,7 +109,7 @@ public: }; QPngHandlerPrivate(QPngHandler *qq) - : gamma(0.0), fileGamma(0.0), quality(50), compression(50), colorSpaceState(Undefined), png_ptr(0), info_ptr(0), end_info(0), state(Ready), q(qq) + : gamma(0.0), fileGamma(0.0), quality(50), compression(50), colorSpaceState(Undefined), png_ptr(nullptr), info_ptr(nullptr), end_info(nullptr), state(Ready), q(qq) { } float gamma; @@ -134,18 +134,18 @@ public: struct AllocatedMemoryPointers { AllocatedMemoryPointers() - : row_pointers(0), accRow(0), inRow(0), outRow(0) + : row_pointers(nullptr), accRow(nullptr), inRow(nullptr), outRow(nullptr) { } void deallocate() { delete [] row_pointers; - row_pointers = 0; + row_pointers = nullptr; delete [] accRow; - accRow = 0; + accRow = nullptr; delete [] inRow; - inRow = 0; + inRow = nullptr; delete [] outRow; - outRow = 0; + outRow = nullptr; } png_byte **row_pointers; @@ -245,13 +245,13 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal png_uint_32 height = 0; int bit_depth = 0; int color_type = 0; - png_bytep trans_alpha = 0; - png_color_16p trans_color_p = 0; + png_bytep trans_alpha = nullptr; + png_color_16p trans_color_p = nullptr; int num_trans; - png_colorp palette = 0; + png_colorp palette = nullptr; int num_palette; int interlace_method = PNG_INTERLACE_LAST; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_method, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_method, nullptr, nullptr); png_set_interlace_handling(png_ptr); if (color_type == PNG_COLOR_TYPE_GRAY) { @@ -343,7 +343,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal if (bit_depth != 1) png_set_packing(png_ptr); png_read_update_info(png_ptr, info_ptr); - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); QImage::Format format = bit_depth == 1 ? QImage::Format_Mono : QImage::Format_Indexed8; if (image.size() != QSize(width, height) || image.format() != format) { image = QImage(width, height, format); @@ -452,7 +452,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i int bit_depth = 0; int color_type = 0; int unit_type = PNG_OFFSET_PIXEL; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type); uchar *data = outImage->bits(); int bpl = outImage->bytesPerLine(); @@ -478,7 +478,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i amp.accRow[i] = rval*amp.inRow[i]; // Accumulate the next input rows for (rval = iysz-rval; rval > 0; rval-=oysz) { - png_read_row(png_ptr, amp.inRow, NULL); + png_read_row(png_ptr, amp.inRow, nullptr); quint32 fact = qMin(oysz, quint32(rval)); for (quint32 i=0; i < ibw; i++) amp.accRow[i] += fact*amp.inRow[i]; @@ -558,11 +558,11 @@ void QPngHandlerPrivate::readPngTexts(png_info *info) bool QPngHandlerPrivate::readPngHeader() { state = Error; - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,nullptr,nullptr,nullptr); if (!png_ptr) return false; - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); + png_set_error_fn(png_ptr, nullptr, nullptr, qt_png_warning); #if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) // Trade off a little bit of memory for better compatibility with existing images @@ -572,21 +572,21 @@ bool QPngHandlerPrivate::readPngHeader() info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_read_struct(&png_ptr, 0, 0); - png_ptr = 0; + png_destroy_read_struct(&png_ptr, nullptr, nullptr); + png_ptr = nullptr; return false; } end_info = png_create_info_struct(png_ptr); if (!end_info) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - png_ptr = 0; + png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + png_ptr = nullptr; return false; } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; return false; } @@ -670,7 +670,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Error; return false; @@ -689,7 +689,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) if (outImage->isNull()) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Error; return false; @@ -706,7 +706,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) int bit_depth = 0; int color_type = 0; int unit_type = PNG_OFFSET_PIXEL; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type); uchar *data = outImage->bits(); int bpl = outImage->bytesPerLine(); @@ -747,7 +747,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) outImage->setText(readTexts.at(i), readTexts.at(i+1)); png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Ready; @@ -767,7 +767,7 @@ QImage::Format QPngHandlerPrivate::readImageFormat() int bit_depth = 0, color_type = 0; png_colorp palette; int num_palette; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); if (color_type == PNG_COLOR_TYPE_GRAY) { // Black & White or grayscale if (bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1) { @@ -910,16 +910,16 @@ bool QPNGImageWriter::writeImage(const QImage& image, int compression_in, const png_structp png_ptr; png_infop info_ptr; - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,nullptr,nullptr,nullptr); if (!png_ptr) { return false; } - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); + png_set_error_fn(png_ptr, nullptr, nullptr, qt_png_warning); info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_write_struct(&png_ptr, 0); + png_destroy_write_struct(&png_ptr, nullptr); return false; } @@ -1022,7 +1022,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int compression_in, const png_set_PLTE(png_ptr, info_ptr, palette, num_palette); if (num_trans) { - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, 0); + png_set_tRNS(png_ptr, info_ptr, trans, num_trans, nullptr); } } diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index cf105b250a..f9424b62bb 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1175,7 +1175,7 @@ QXpmHandler::QXpmHandler() bool QXpmHandler::readHeader() { state = Error; - if (!read_xpm_header(device(), 0, index, buffer, &cpp, &ncols, &width, &height)) + if (!read_xpm_header(device(), nullptr, index, buffer, &cpp, &ncols, &width, &height)) return false; state = ReadHeader; return true; @@ -1191,7 +1191,7 @@ bool QXpmHandler::readImage(QImage *image) return false; } - if (!read_xpm_body(device(), 0, index, buffer, cpp, ncols, width, height, *image)) { + if (!read_xpm_body(device(), nullptr, index, buffer, cpp, ncols, width, height, *image)) { state = Error; return false; } diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 2390c62b9f..2998808b54 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -130,7 +130,7 @@ void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, } if (item) { - if (item->d_func()->parent == 0) { + if (item->d_func()->parent == nullptr) { item->d_func()->setParentAndModel(q, model); } else { qWarning("QStandardItem::setChild: Ignoring duplicate insertion of item %p", @@ -139,7 +139,7 @@ void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, } } if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; children.replace(index, item); if (item) @@ -412,7 +412,7 @@ void QStandardItemPrivate::setModel(QStandardItemModel *mod) */ QStandardItemModelPrivate::QStandardItemModelPrivate() : root(new QStandardItem), - itemPrototype(0), + itemPrototype(nullptr), sortRole(Qt::DisplayRole) { root->setFlags(Qt::ItemIsDropEnabled); @@ -510,12 +510,12 @@ bool QStandardItemPrivate::insertRows(int row, int count, const QListd_func()->parent == 0) { + if (item->d_func()->parent == nullptr) { item->d_func()->setParentAndModel(q, model); } else { qWarning("QStandardItem::insertRows: Ignoring duplicate insertion of item %p", item); - item = 0; + item = nullptr; } } children.replace(index, item); @@ -555,12 +555,12 @@ bool QStandardItemPrivate::insertColumns(int column, int count, const QListd_func()->parent == 0) { + if (item->d_func()->parent == nullptr) { item->d_func()->setParentAndModel(q, model); } else { qWarning("QStandardItem::insertColumns: Ignoring duplicate insertion of item %p", item); - item = 0; + item = nullptr; } } int r = i / count; @@ -583,7 +583,7 @@ void QStandardItemModelPrivate::itemChanged(QStandardItem *item, const QVectord_func()->parent == 0) { + if (item->d_func()->parent == nullptr) { // Header item int idx = columnHeaderItems.indexOf(item); if (idx != -1) { @@ -679,7 +679,7 @@ void QStandardItemModelPrivate::rowsRemoved(QStandardItem *parent, for (int i = row; i < row + count; ++i) { QStandardItem *oldItem = rowHeaderItems.at(i); if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; } rowHeaderItems.remove(row, count); @@ -698,7 +698,7 @@ void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent, for (int i = column; i < column + count; ++i) { QStandardItem *oldItem = columnHeaderItems.at(i); if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; } columnHeaderItems.remove(column, count); @@ -870,7 +870,7 @@ QStandardItem::~QStandardItem() Q_D(QStandardItem); for (QStandardItem *child : qAsConst(d->children)) { if (child) - child->d_func()->setModel(0); + child->d_func()->setModel(nullptr); delete child; } d->children.clear(); @@ -890,7 +890,7 @@ QStandardItem *QStandardItem::parent() const Q_D(const QStandardItem); if (!d->model || (d->model->d_func()->root.data() != d->parent)) return d->parent; - return 0; + return nullptr; } /*! @@ -1794,7 +1794,7 @@ void QStandardItem::removeRows(int row, int count) for (int j = i; j < n+i; ++j) { QStandardItem *oldItem = d->children.at(j); if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; } d->children.remove(qMax(i, 0), n); @@ -1821,7 +1821,7 @@ void QStandardItem::removeColumns(int column, int count) for (int j=i; jchildren.at(j); if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; } d->children.remove(i, count); @@ -1874,7 +1874,7 @@ QStandardItem *QStandardItem::child(int row, int column) const Q_D(const QStandardItem); int index = d->childIndex(row, column); if (index == -1) - return 0; + return nullptr; return d->children.at(index); } @@ -1891,12 +1891,12 @@ QStandardItem *QStandardItem::child(int row, int column) const QStandardItem *QStandardItem::takeChild(int row, int column) { Q_D(QStandardItem); - QStandardItem *item = 0; + QStandardItem *item = nullptr; int index = d->childIndex(row, column); if (index != -1) { item = d->children.at(index); if (item) - item->d_func()->setParentAndModel(0, 0); + item->d_func()->setParentAndModel(nullptr, nullptr); d->children.replace(index, 0); } return item; @@ -1925,7 +1925,7 @@ QList QStandardItem::takeRow(int row) for (int column = 0; column < col_count; ++column) { QStandardItem *ch = d->children.at(index + column); if (ch) - ch->d_func()->setParentAndModel(0, 0); + ch->d_func()->setParentAndModel(nullptr, nullptr); items.append(ch); } d->children.remove(index, col_count); @@ -1958,7 +1958,7 @@ QList QStandardItem::takeColumn(int column) int index = d->childIndex(row, column); QStandardItem *ch = d->children.at(index); if (ch) - ch->d_func()->setParentAndModel(0, 0); + ch->d_func()->setParentAndModel(nullptr, nullptr); d->children.remove(index); items.prepend(ch); } @@ -2291,13 +2291,13 @@ QStandardItem *QStandardItemModel::itemFromIndex(const QModelIndex &index) const { Q_D(const QStandardItemModel); if ((index.row() < 0) || (index.column() < 0) || (index.model() != this)) - return 0; + return nullptr; QStandardItem *parent = static_cast(index.internalPointer()); - if (parent == 0) - return 0; + if (parent == nullptr) + return nullptr; QStandardItem *item = parent->child(index.row(), index.column()); // lazy part - if (item == 0) { + if (item == nullptr) { item = d->createItem(); parent->d_func()->setChild(index.row(), index.column(), item); } @@ -2432,7 +2432,7 @@ void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item return; if (item) { - if (item->model() == 0) { + if (item->model() == nullptr) { item->d_func()->setModel(this); } else { qWarning("QStandardItem::setHorizontalHeaderItem: Ignoring duplicate insertion of item %p", @@ -2442,7 +2442,7 @@ void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item } if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; d->columnHeaderItems.replace(column, item); @@ -2461,7 +2461,7 @@ QStandardItem *QStandardItemModel::horizontalHeaderItem(int column) const { Q_D(const QStandardItemModel); if ((column < 0) || (column >= columnCount())) - return 0; + return nullptr; return d->columnHeaderItems.at(column); } @@ -2488,7 +2488,7 @@ void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item) return; if (item) { - if (item->model() == 0) { + if (item->model() == nullptr) { item->d_func()->setModel(this); } else { qWarning("QStandardItem::setVerticalHeaderItem: Ignoring duplicate insertion of item %p", @@ -2498,7 +2498,7 @@ void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item) } if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; d->rowHeaderItems.replace(row, item); @@ -2517,7 +2517,7 @@ QStandardItem *QStandardItemModel::verticalHeaderItem(int row) const { Q_D(const QStandardItemModel); if ((row < 0) || (row >= rowCount())) - return 0; + return nullptr; return d->rowHeaderItems.at(row); } @@ -2757,10 +2757,10 @@ QStandardItem *QStandardItemModel::takeHorizontalHeaderItem(int column) { Q_D(QStandardItemModel); if ((column < 0) || (column >= columnCount())) - return 0; + return nullptr; QStandardItem *headerItem = d->columnHeaderItems.at(column); if (headerItem) { - headerItem->d_func()->setParentAndModel(0, 0); + headerItem->d_func()->setParentAndModel(nullptr, nullptr); d->columnHeaderItems.replace(column, 0); } return headerItem; @@ -2779,10 +2779,10 @@ QStandardItem *QStandardItemModel::takeVerticalHeaderItem(int row) { Q_D(QStandardItemModel); if ((row < 0) || (row >= rowCount())) - return 0; + return nullptr; QStandardItem *headerItem = d->rowHeaderItems.at(row); if (headerItem) { - headerItem->d_func()->setParentAndModel(0, 0); + headerItem->d_func()->setParentAndModel(nullptr, nullptr); d->rowHeaderItems.replace(row, 0); } return headerItem; @@ -2876,7 +2876,7 @@ QVariant QStandardItemModel::headerData(int section, Qt::Orientation orientation || ((orientation == Qt::Vertical) && (section >= rowCount()))) { return QVariant(); } - QStandardItem *headerItem = 0; + QStandardItem *headerItem = nullptr; if (orientation == Qt::Horizontal) headerItem = d->columnHeaderItems.at(section); else if (orientation == Qt::Vertical) @@ -2902,7 +2902,7 @@ QModelIndex QStandardItemModel::index(int row, int column, const QModelIndex &pa { Q_D(const QStandardItemModel); QStandardItem *parentItem = d->itemFromIndex(parent); - if ((parentItem == 0) + if ((parentItem == nullptr) || (row < 0) || (column < 0) || (row >= parentItem->rowCount()) @@ -2919,7 +2919,7 @@ bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex { Q_D(QStandardItemModel); QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); - if (item == 0) + if (item == nullptr) return false; return item->d_func()->insertColumns(column, count, QList()); } @@ -2931,7 +2931,7 @@ bool QStandardItemModel::insertRows(int row, int count, const QModelIndex &paren { Q_D(QStandardItemModel); QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); - if (item == 0) + if (item == nullptr) return false; return item->d_func()->insertRows(row, count, QList()); } @@ -2967,7 +2967,7 @@ bool QStandardItemModel::removeColumns(int column, int count, const QModelIndex { Q_D(QStandardItemModel); QStandardItem *item = d->itemFromIndex(parent); - if ((item == 0) || (count < 1) || (column < 0) || ((column + count) > item->columnCount())) + if ((item == nullptr) || (count < 1) || (column < 0) || ((column + count) > item->columnCount())) return false; item->removeColumns(column, count); return true; @@ -2980,7 +2980,7 @@ bool QStandardItemModel::removeRows(int row, int count, const QModelIndex &paren { Q_D(QStandardItemModel); QStandardItem *item = d->itemFromIndex(parent); - if ((item == 0) || (count < 1) || (row < 0) || ((row + count) > item->rowCount())) + if ((item == nullptr) || (count < 1) || (row < 0) || ((row + count) > item->rowCount())) return false; item->removeRows(row, count); return true; @@ -3004,7 +3004,7 @@ bool QStandardItemModel::setData(const QModelIndex &index, const QVariant &value if (!index.isValid()) return false; QStandardItem *item = itemFromIndex(index); - if (item == 0) + if (item == nullptr) return false; item->setData(value, role); return true; @@ -3047,17 +3047,17 @@ bool QStandardItemModel::setHeaderData(int section, Qt::Orientation orientation, || ((orientation == Qt::Vertical) && (section >= rowCount()))) { return false; } - QStandardItem *headerItem = 0; + QStandardItem *headerItem = nullptr; if (orientation == Qt::Horizontal) { headerItem = d->columnHeaderItems.at(section); - if (headerItem == 0) { + if (headerItem == nullptr) { headerItem = d->createItem(); headerItem->d_func()->setModel(this); d->columnHeaderItems.replace(section, headerItem); } } else if (orientation == Qt::Vertical) { headerItem = d->rowHeaderItems.at(section); - if (headerItem == 0) { + if (headerItem == nullptr) { headerItem = d->createItem(); headerItem->d_func()->setModel(this); d->rowHeaderItems.replace(section, headerItem); @@ -3076,7 +3076,7 @@ bool QStandardItemModel::setHeaderData(int section, Qt::Orientation orientation, bool QStandardItemModel::setItemData(const QModelIndex &index, const QMap &roles) { QStandardItem *item = itemFromIndex(index); - if (item == 0) + if (item == nullptr) return false; item->d_func()->setItemData(roles); return true; @@ -3106,7 +3106,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const { QMimeData *data = QAbstractItemModel::mimeData(indexes); if(!data) - return 0; + return nullptr; const QString format = qStandardItemModelDataListMimeType(); if (!mimeTypes().contains(format)) @@ -3124,7 +3124,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const stack.push(item); } else { qWarning("QStandardItemModel::mimeData: No item associated with invalid index"); - return 0; + return nullptr; } } diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index 267c079ad9..db22ef2486 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -461,7 +461,7 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode) const QMimeData* QClipboard::mimeData(Mode mode) const { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); - if (!clipboard->supportsMode(mode)) return 0; + if (!clipboard->supportsMode(mode)) return nullptr; return clipboard->mimeData(mode); } @@ -488,7 +488,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode) { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); if (!clipboard->supportsMode(mode)) { - if (src != 0) { + if (src != nullptr) { qDebug("Data set on unsupported clipboard mode. QMimeData object will be deleted."); src->deleteLater(); } @@ -512,7 +512,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode) */ void QClipboard::clear(Mode mode) { - setMimeData(0, mode); + setMimeData(nullptr, mode); } /*! diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 1ba8760a9d..4ae5412367 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -384,7 +384,7 @@ QDataStream &operator>>(QDataStream &s, QCursor &c) */ QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY) - : d(0) + : d(nullptr) { QImage img = pixmap.toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither); QBitmap bm = QBitmap::fromImage(img, Qt::ThresholdDither|Qt::AvoidDither); @@ -440,7 +440,7 @@ QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY) */ QCursor::QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) - : d(0) + : d(nullptr) { d = QCursorData::setBitmap(bitmap, mask, hotX, hotY, 1.0); } @@ -452,7 +452,7 @@ QCursor::QCursor() { if (!QCursorData::initialized) { if (QCoreApplication::startingUp()) { - d = 0; + d = nullptr; return; } QCursorData::initialize(); @@ -470,7 +470,7 @@ QCursor::QCursor() \sa setShape() */ QCursor::QCursor(Qt::CursorShape shape) - : d(0) + : d(nullptr) { if (!QCursorData::initialized) QCursorData::initialize(); @@ -550,7 +550,7 @@ void QCursor::setShape(Qt::CursorShape shape) { if (!QCursorData::initialized) QCursorData::initialize(); - QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : 0; + QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : nullptr; if (!c) c = qt_cursorTable[0]; c->ref.ref(); @@ -675,7 +675,7 @@ QCursorData *qt_cursorTable[Qt::LastCursor + 1]; bool QCursorData::initialized = false; QCursorData::QCursorData(Qt::CursorShape s) - : ref(1), cshape(s), bm(0), bmm(0), hx(0), hy(0) + : ref(1), cshape(s), bm(nullptr), bmm(nullptr), hx(0), hy(0) { } @@ -695,7 +695,7 @@ void QCursorData::cleanup() // In case someone has a static QCursor defined with this shape if (!qt_cursorTable[shape]->ref.deref()) delete qt_cursorTable[shape]; - qt_cursorTable[shape] = 0; + qt_cursorTable[shape] = nullptr; } QCursorData::initialized = false; } diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index dd541af3b8..fe766c900e 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -48,19 +48,19 @@ QT_BEGIN_NAMESPACE // the universe's only drag manager -QDragManager *QDragManager::m_instance = 0; +QDragManager *QDragManager::m_instance = nullptr; QDragManager::QDragManager() - : QObject(qApp), m_currentDropTarget(0), + : QObject(qApp), m_currentDropTarget(nullptr), m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()), - m_object(0) + m_object(nullptr) { Q_ASSERT(!m_instance); } QDragManager::~QDragManager() { - m_instance = 0; + m_instance = nullptr; } QDragManager *QDragManager::self() @@ -74,7 +74,7 @@ QObject *QDragManager::source() const { if (m_object) return m_object->source(); - return 0; + return nullptr; } void QDragManager::setCurrentTarget(QObject *target, bool dropped) @@ -111,7 +111,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) m_object = o; - m_object->d_func()->target = 0; + m_object->d_func()->target = nullptr; QGuiApplicationPrivate::instance()->notifyDragStarted(m_object.data()); const Qt::DropAction result = m_platformDrag->drag(m_object); diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 8e2f7be23e..3712eace15 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -112,8 +112,8 @@ QDrag::QDrag(QObject *dragSource) { Q_D(QDrag); d->source = dragSource; - d->target = 0; - d->data = 0; + d->target = nullptr; + d->data = nullptr; d->hotspot = QPoint(-10, -10); d->executed_action = Qt::IgnoreAction; d->supported_actions = Qt::IgnoreAction; @@ -138,7 +138,7 @@ void QDrag::setMimeData(QMimeData *data) Q_D(QDrag); if (d->data == data) return; - if (d->data != 0) + if (d->data != nullptr) delete d->data; d->data = data; } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f555f4dc05..c69cc8ce6f 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2950,7 +2950,7 @@ QObject* QDropEvent::source() const { if (const QDragManager *manager = QDragManager::self()) return manager->source(); - return 0; + return nullptr; } @@ -4315,8 +4315,8 @@ QTouchEvent::QTouchEvent(QEvent::Type eventType, Qt::TouchPointStates touchPointStates, const QList &touchPoints) : QInputEvent(eventType, modifiers), - _window(0), - _target(0), + _window(nullptr), + _target(nullptr), _device(device), _touchPointStates(touchPointStates), _touchPoints(touchPoints) @@ -5008,7 +5008,7 @@ void QTouchEvent::TouchPoint::setFlags(InfoFlags flags) The \a startPos is the position of a touch or mouse event that started the scrolling. */ QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos) - : QEvent(QEvent::ScrollPrepare), m_target(0), m_startPos(startPos) + : QEvent(QEvent::ScrollPrepare), m_target(nullptr), m_startPos(startPos) { Q_UNUSED(m_target); } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index ef31e475ea..6a0b01b6c3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -141,7 +141,7 @@ Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; QPointF QGuiApplicationPrivate::lastCursorPosition(qInf(), qInf()); -QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; +QWindow *QGuiApplicationPrivate::currentMouseWindow = nullptr; QString QGuiApplicationPrivate::styleOverride; @@ -155,8 +155,8 @@ QPointer QGuiApplicationPrivate::currentDragWindow; QVector QGuiApplicationPrivate::tabletDevicePoints; -QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; -QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; +QPlatformIntegration *QGuiApplicationPrivate::platform_integration = nullptr; +QPlatformTheme *QGuiApplicationPrivate::platform_theme = nullptr; QList QGuiApplicationPrivate::generic_plugin_list; @@ -172,13 +172,13 @@ enum ApplicationResourceFlags static unsigned applicationResourceFlags = 0; -QIcon *QGuiApplicationPrivate::app_icon = 0; +QIcon *QGuiApplicationPrivate::app_icon = nullptr; -QString *QGuiApplicationPrivate::platform_name = 0; -QString *QGuiApplicationPrivate::displayName = 0; -QString *QGuiApplicationPrivate::desktopFileName = 0; +QString *QGuiApplicationPrivate::platform_name = nullptr; +QString *QGuiApplicationPrivate::displayName = nullptr; +QString *QGuiApplicationPrivate::desktopFileName = nullptr; -QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette +QPalette *QGuiApplicationPrivate::app_pal = nullptr; // default application palette ulong QGuiApplicationPrivate::mousePressTime = 0; Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton; @@ -188,30 +188,30 @@ int QGuiApplicationPrivate::mousePressY = 0; static int mouseDoubleClickDistance = -1; static int touchDoubleTapDistance = -1; -QWindow *QGuiApplicationPrivate::currentMousePressWindow = 0; +QWindow *QGuiApplicationPrivate::currentMousePressWindow = nullptr; static Qt::LayoutDirection layout_direction = Qt::LayoutDirectionAuto; static bool force_reverse = false; -QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0; -QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = 0; +QGuiApplicationPrivate *QGuiApplicationPrivate::self = nullptr; +QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = nullptr; int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0; #ifndef QT_NO_CLIPBOARD -QClipboard *QGuiApplicationPrivate::qt_clipboard = 0; +QClipboard *QGuiApplicationPrivate::qt_clipboard = nullptr; #endif QList QGuiApplicationPrivate::screen_list; QWindowList QGuiApplicationPrivate::window_list; -QWindow *QGuiApplicationPrivate::focus_window = 0; +QWindow *QGuiApplicationPrivate::focus_window = nullptr; static QBasicMutex applicationFontMutex; -QFont *QGuiApplicationPrivate::app_font = 0; +QFont *QGuiApplicationPrivate::app_font = nullptr; QStyleHints *QGuiApplicationPrivate::styleHints = nullptr; bool QGuiApplicationPrivate::obey_desktop_settings = true; -QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = 0; +QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = nullptr; qreal QGuiApplicationPrivate::m_maxDevicePixelRatio = 0.0; @@ -243,7 +243,7 @@ static void initPalette() static inline void clearPalette() { delete QGuiApplicationPrivate::app_pal; - QGuiApplicationPrivate::app_pal = 0; + QGuiApplicationPrivate::app_pal = nullptr; } static void initFontUnlocked() @@ -261,7 +261,7 @@ static void initFontUnlocked() static inline void clearFontUnlocked() { delete QGuiApplicationPrivate::app_font; - QGuiApplicationPrivate::app_font = 0; + QGuiApplicationPrivate::app_font = nullptr; } static void initThemeHints() @@ -656,16 +656,16 @@ QGuiApplication::~QGuiApplication() Q_D(QGuiApplication); d->eventDispatcher->closingDown(); - d->eventDispatcher = 0; + d->eventDispatcher = nullptr; #ifndef QT_NO_CLIPBOARD delete QGuiApplicationPrivate::qt_clipboard; - QGuiApplicationPrivate::qt_clipboard = 0; + QGuiApplicationPrivate::qt_clipboard = nullptr; #endif #ifndef QT_NO_SESSIONMANAGER delete d->session_manager; - d->session_manager = 0; + d->session_manager = nullptr; #endif //QT_NO_SESSIONMANAGER clearPalette(); @@ -676,15 +676,15 @@ QGuiApplication::~QGuiApplication() #endif delete QGuiApplicationPrivate::app_icon; - QGuiApplicationPrivate::app_icon = 0; + QGuiApplicationPrivate::app_icon = nullptr; delete QGuiApplicationPrivate::platform_name; - QGuiApplicationPrivate::platform_name = 0; + QGuiApplicationPrivate::platform_name = nullptr; delete QGuiApplicationPrivate::displayName; - QGuiApplicationPrivate::displayName = 0; + QGuiApplicationPrivate::displayName = nullptr; delete QGuiApplicationPrivate::m_inputDeviceManager; - QGuiApplicationPrivate::m_inputDeviceManager = 0; + QGuiApplicationPrivate::m_inputDeviceManager = nullptr; delete QGuiApplicationPrivate::desktopFileName; - QGuiApplicationPrivate::desktopFileName = 0; + QGuiApplicationPrivate::desktopFileName = nullptr; QGuiApplicationPrivate::mouse_buttons = Qt::NoButton; QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; QGuiApplicationPrivate::lastCursorPosition = {qInf(), qInf()}; @@ -704,7 +704,7 @@ QGuiApplication::~QGuiApplication() QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) : QCoreApplicationPrivate(argc, argv, flags), - inputMethod(0), + inputMethod(nullptr), lastTouchType(QEvent::TouchEnd), ownGlobalShareContext(false) { @@ -797,7 +797,7 @@ QWindow *QGuiApplication::modalWindow() { CHECK_QAPP_INSTANCE(nullptr) if (QGuiApplicationPrivate::self->modalWindowList.isEmpty()) - return 0; + return nullptr; return QGuiApplicationPrivate::self->modalWindowList.first(); } @@ -844,7 +844,7 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) self->modalWindowList.removeFirst(); QEvent e(QEvent::Leave); QGuiApplication::sendEvent(currentMouseWindow, &e); - currentMouseWindow = 0; + currentMouseWindow = nullptr; self->modalWindowList.prepend(modal); } } @@ -874,12 +874,12 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window) */ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const { - QWindow *unused = 0; + QWindow *unused = nullptr; if (!blockingWindow) blockingWindow = &unused; if (modalWindowList.isEmpty()) { - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -889,7 +889,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking // A window is not blocked by another modal window if the two are // the same, or if the window is a child of the modal window. if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) { - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -930,7 +930,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking break; } } - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -969,7 +969,7 @@ QObject *QGuiApplication::focusObject() { if (focusWindow()) return focusWindow()->focusObject(); - return 0; + return nullptr; } /*! @@ -1022,7 +1022,7 @@ QWindowList QGuiApplication::topLevelWindows() QScreen *QGuiApplication::primaryScreen() { if (QGuiApplicationPrivate::screen_list.isEmpty()) - return 0; + return nullptr; return QGuiApplicationPrivate::screen_list.at(0); } @@ -1450,7 +1450,7 @@ void QGuiApplicationPrivate::createPlatformIntegration() } if (j < argc) { - argv[j] = 0; + argv[j] = nullptr; argc = j; } @@ -1470,7 +1470,7 @@ void QGuiApplicationPrivate::createEventDispatcher() { Q_ASSERT(!eventDispatcher); - if (platform_integration == 0) + if (platform_integration == nullptr) createPlatformIntegration(); // The platform integration should not mess with the event dispatcher @@ -1481,7 +1481,7 @@ void QGuiApplicationPrivate::createEventDispatcher() void QGuiApplicationPrivate::eventDispatcherReady() { - if (platform_integration == 0) + if (platform_integration == nullptr) createPlatformIntegration(); platform_integration->initialize(); @@ -1578,7 +1578,7 @@ void QGuiApplicationPrivate::init() } if (j < argc) { - argv[j] = 0; + argv[j] = nullptr; argc = j; } @@ -1587,7 +1587,7 @@ void QGuiApplicationPrivate::init() if (!envPlugins.isEmpty()) pluginList += envPlugins.split(','); - if (platform_integration == 0) + if (platform_integration == nullptr) createPlatformIntegration(); initPalette(); @@ -1693,16 +1693,16 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() #ifndef QT_NO_OPENGL if (ownGlobalShareContext) { delete qt_gl_global_share_context(); - qt_gl_set_global_share_context(0); + qt_gl_set_global_share_context(nullptr); } #endif platform_integration->destroy(); delete platform_theme; - platform_theme = 0; + platform_theme = nullptr; delete platform_integration; - platform_integration = 0; + platform_integration = nullptr; window_list.clear(); screen_list.clear(); @@ -1793,7 +1793,7 @@ Qt::MouseButtons QGuiApplication::mouseButtons() QPlatformNativeInterface *QGuiApplication::platformNativeInterface() { QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); - return pi ? pi->nativeInterface() : 0; + return pi ? pi->nativeInterface() : nullptr; } /*! @@ -2144,7 +2144,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo window = currentMousePressWindow; } else if (currentMousePressWindow) { window = currentMousePressWindow; - currentMousePressWindow = 0; + currentMousePressWindow = nullptr; } QPointF delta = globalPoint - globalPoint.toPoint(); localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; @@ -2357,7 +2357,7 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le return; } - currentMouseWindow = 0; + currentMouseWindow = nullptr; QEvent event(QEvent::Leave); QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event); @@ -2376,7 +2376,7 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate if (platformWindow->isAlertState()) platformWindow->setAlertState(false); - QObject *previousFocusObject = previous ? previous->focusObject() : 0; + QObject *previousFocusObject = previous ? previous->focusObject() : nullptr; if (previous) { QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); @@ -2445,7 +2445,7 @@ void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterf if (QScreen *screen = wse->screen.data()) topLevelWindow->d_func()->setTopLevelScreen(screen, false /* recreate */); else // Fall back to default behavior, and try to find some appropriate screen - topLevelWindow->setScreen(0); + topLevelWindow->setScreen(nullptr); } // we may have changed scaling, so trigger resize event if needed if (window->handle()) { @@ -2871,7 +2871,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To break; } - Q_ASSERT(w.data() != 0); + Q_ASSERT(w.data() != nullptr); // make the *scene* functions return the same as the *screen* functions // Note: touchPoint is a reference to the one from activeTouchPoints, @@ -3247,12 +3247,12 @@ QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QM */ QClipboard * QGuiApplication::clipboard() { - if (QGuiApplicationPrivate::qt_clipboard == 0) { + if (QGuiApplicationPrivate::qt_clipboard == nullptr) { if (!qApp) { qWarning("QGuiApplication: Must construct a QGuiApplication before accessing a QClipboard"); - return 0; + return nullptr; } - QGuiApplicationPrivate::qt_clipboard = new QClipboard(0); + QGuiApplicationPrivate::qt_clipboard = new QClipboard(nullptr); } return QGuiApplicationPrivate::qt_clipboard; } @@ -3873,7 +3873,7 @@ Qt::LayoutDirection QGuiApplication::layoutDirection() QCursor *QGuiApplication::overrideCursor() { CHECK_QAPP_INSTANCE(nullptr) - return qGuiApp->d_func()->cursor_list.isEmpty() ? 0 : &qGuiApp->d_func()->cursor_list.first(); + return qGuiApp->d_func()->cursor_list.isEmpty() ? nullptr : &qGuiApp->d_func()->cursor_list.first(); } /*! @@ -3907,7 +3907,7 @@ static inline void unsetCursor(QWindow *w) { if (const QScreen *screen = w->screen()) if (QPlatformCursor *cursor = screen->handle()->cursor()) - cursor->changeCursor(0, w); + cursor->changeCursor(nullptr, w); } static inline void applyCursor(const QList &l, const QCursor &c) diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index edca8d9423..4ed9d032f6 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -103,13 +103,13 @@ static void construct(QVariant::Private *x, const void *copy) { const int type = x->type; QVariantConstructor constructor(x, copy); - QMetaTypeSwitcher::switcher(constructor, type, 0); + QMetaTypeSwitcher::switcher(constructor, type, nullptr); } static void clear(QVariant::Private *d) { QVariantDestructor destructor(d); - QMetaTypeSwitcher::switcher(destructor, d->type, 0); + QMetaTypeSwitcher::switcher(destructor, d->type, nullptr); } // This class is a hack that customizes access to QPolygon and QPolygonF @@ -129,7 +129,7 @@ public: static bool isNull(const QVariant::Private *d) { QGuiVariantIsNull isNull(d); - return QMetaTypeSwitcher::switcher(isNull, d->type, 0); + return QMetaTypeSwitcher::switcher(isNull, d->type, nullptr); } // This class is a hack that customizes access to QPixmap, QBitmap, QCursor and QIcon @@ -171,7 +171,7 @@ public: static bool compare(const QVariant::Private *a, const QVariant::Private *b) { QGuiVariantComparator comparator(a, b); - return QMetaTypeSwitcher::switcher(comparator, a->type, 0); + return QMetaTypeSwitcher::switcher(comparator, a->type, nullptr); } static bool convert(const QVariant::Private *d, int t, @@ -311,7 +311,7 @@ static void streamDebug(QDebug dbg, const QVariant &v) { QVariant::Private *d = const_cast(&v.data_ptr()); QVariantDebugStream stream(dbg, d); - QMetaTypeSwitcher::switcher(stream, d->type, 0); + QMetaTypeSwitcher::switcher(stream, d->type, nullptr); } #endif @@ -320,12 +320,12 @@ const QVariant::Handler qt_gui_variant_handler = { clear, isNull, #ifndef QT_NO_DATASTREAM - 0, - 0, + nullptr, + nullptr, #endif compare, convert, - 0, + nullptr, #if !defined(QT_NO_DEBUG_STREAM) streamDebug #else diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp index 4893b1d57b..274574f561 100644 --- a/src/gui/kernel/qkeymapper.cpp +++ b/src/gui/kernel/qkeymapper.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE Constructs a new key mapper. */ QKeyMapper::QKeyMapper() - : QObject(*new QKeyMapperPrivate, 0) + : QObject(*new QKeyMapperPrivate, nullptr) { } diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index 0cc11ca3bb..c74fe0b3a1 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -99,10 +99,10 @@ public: QOffscreenSurfacePrivate() : QObjectPrivate() , surfaceType(QSurface::OpenGLSurface) - , platformOffscreenSurface(0) - , offscreenWindow(0) + , platformOffscreenSurface(nullptr) + , offscreenWindow(nullptr) , requestedFormat(QSurfaceFormat::defaultFormat()) - , screen(0) + , screen(nullptr) , size(1, 1) , nativeHandle(nullptr) { @@ -235,11 +235,11 @@ void QOffscreenSurface::destroy() QGuiApplication::sendEvent(this, &e); delete d->platformOffscreenSurface; - d->platformOffscreenSurface = 0; + d->platformOffscreenSurface = nullptr; if (d->offscreenWindow) { d->offscreenWindow->destroy(); delete d->offscreenWindow; - d->offscreenWindow = 0; + d->offscreenWindow = nullptr; } d->nativeHandle = nullptr; @@ -341,7 +341,7 @@ void QOffscreenSurface::setScreen(QScreen *newScreen) if (!newScreen) newScreen = QCoreApplication::instance() ? QGuiApplication::primaryScreen() : nullptr; if (newScreen != d->screen) { - const bool wasCreated = d->platformOffscreenSurface != 0 || d->offscreenWindow != 0; + const bool wasCreated = d->platformOffscreenSurface != nullptr || d->offscreenWindow != nullptr; if (wasCreated) destroy(); if (d->screen) @@ -385,7 +385,7 @@ void QOffscreenSurface::screenDestroyed(QObject *object) { Q_D(QOffscreenSurface); if (object == static_cast(d->screen)) - setScreen(0); + setScreen(nullptr); } /*! diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 638eb1d12f..124b39f2a9 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -223,7 +223,7 @@ class QGuiGLThreadContext { public: QGuiGLThreadContext() - : context(0) + : context(nullptr) { } ~QGuiGLThreadContext() { @@ -234,7 +234,7 @@ public: }; Q_GLOBAL_STATIC(QThreadStorage, qwindow_context_storage); -static QOpenGLContext *global_share_context = 0; +static QOpenGLContext *global_share_context = nullptr; #ifndef QT_NO_DEBUG QHash QOpenGLContextPrivate::makeCurrentTracker; @@ -347,7 +347,7 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context if (!threadContext) { if (!QThread::currentThread()) { qWarning("No QTLS available. currentContext won't work"); - return 0; + return nullptr; } threadContext = new QGuiGLThreadContext; qwindow_context_storage()->setLocalData(threadContext); @@ -372,10 +372,10 @@ int QOpenGLContextPrivate::maxTextureSize() GLint size; GLint next = 64; - funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); - QOpenGLFunctions_1_0 *gl1funcs = 0; - QOpenGLFunctions_3_2_Core *gl3funcs = 0; + QOpenGLFunctions_1_0 *gl1funcs = nullptr; + QOpenGLFunctions_3_2_Core *gl3funcs = nullptr; if (q->format().profile() == QSurfaceFormat::CoreProfile) gl3funcs = q->versionFunctions(); @@ -398,7 +398,7 @@ int QOpenGLContextPrivate::maxTextureSize() if (next > max_texture_size) break; - funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); if (gl1funcs) gl1funcs->glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &next); else @@ -455,7 +455,7 @@ QPlatformOpenGLContext *QOpenGLContext::shareHandle() const Q_D(const QOpenGLContext); if (d->shareContext) return d->shareContext->handle(); - return 0; + return nullptr; } /*! @@ -517,8 +517,8 @@ void QOpenGLContextPrivate::_q_screenDestroyed(QObject *object) { Q_Q(QOpenGLContext); if (object == static_cast(screen)) { - screen = 0; - q->setScreen(0); + screen = nullptr; + q->setScreen(nullptr); } } @@ -615,7 +615,7 @@ bool QOpenGLContext::create() d->platformGLContext->setContext(this); d->platformGLContext->initialize(); if (!d->platformGLContext->isSharing()) - d->shareContext = 0; + d->shareContext = nullptr; d->shareGroup = d->shareContext ? d->shareContext->shareGroup() : new QOpenGLContextGroup; d->shareGroup->d_func()->addContext(this); return isValid(); @@ -649,15 +649,15 @@ void QOpenGLContext::destroy() doneCurrent(); if (d->shareGroup) d->shareGroup->d_func()->removeContext(this); - d->shareGroup = 0; + d->shareGroup = nullptr; delete d->platformGLContext; - d->platformGLContext = 0; + d->platformGLContext = nullptr; delete d->functions; - d->functions = 0; + d->functions = nullptr; for (QAbstractOpenGLFunctions *func : qAsConst(d->externalVersionFunctions)) { QAbstractOpenGLFunctionsPrivate *func_d = QAbstractOpenGLFunctionsPrivate::get(func); - func_d->owningContext = 0; + func_d->owningContext = nullptr; func_d->initialized = false; } d->externalVersionFunctions.clear(); @@ -665,7 +665,7 @@ void QOpenGLContext::destroy() d->versionFunctions.clear(); delete d->textureFunctions; - d->textureFunctions = 0; + d->textureFunctions = nullptr; d->nativeHandle = QVariant(); } @@ -823,7 +823,7 @@ QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionP #ifndef QT_OPENGL_ES_2 if (isOpenGLES()) { qWarning("versionFunctions: Not supported on OpenGL ES"); - return 0; + return nullptr; } #endif // QT_OPENGL_ES_2 @@ -838,16 +838,16 @@ QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionP // Check that context is compatible with requested version const QPair v = qMakePair(f.majorVersion(), f.minorVersion()); if (v < vp.version()) - return 0; + return nullptr; // If this context only offers core profile functions then we can't create // function objects for legacy or compatibility profile requests if (((vp.hasProfiles() && vp.profile() != QSurfaceFormat::CoreProfile) || vp.isLegacyVersion()) && f.profile() == QSurfaceFormat::CoreProfile) - return 0; + return nullptr; // Create object if suitable one not cached - QAbstractOpenGLFunctions* funcs = 0; + QAbstractOpenGLFunctions* funcs = nullptr; auto it = d->versionFunctions.constFind(vp); if (it == d->versionFunctions.constEnd()) { funcs = QOpenGLVersionFunctionsFactory::create(vp); @@ -1022,7 +1022,7 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) || qstrncmp(rendererString, "Adreno 6xx", 8) == 0 // Same as above but without the '(TM)' || qstrcmp(rendererString, "GC800 core") == 0 || qstrcmp(rendererString, "GC1000 core") == 0 - || strstr(rendererString, "GC2000") != 0 + || strstr(rendererString, "GC2000") != nullptr || qstrcmp(rendererString, "Immersion.16") == 0; } needsWorkaroundSet = true; @@ -1053,9 +1053,9 @@ void QOpenGLContext::doneCurrent() d->shareGroup->d_func()->deletePendingResources(this); d->platformGLContext->doneCurrent(); - QOpenGLContextPrivate::setCurrentContext(0); + QOpenGLContextPrivate::setCurrentContext(nullptr); - d->surface = 0; + d->surface = nullptr; } /*! @@ -1224,8 +1224,8 @@ void QOpenGLContext::deleteQGLContext() Q_D(QOpenGLContext); if (d->qGLContextDeleteFunction && d->qGLContextHandle) { d->qGLContextDeleteFunction(d->qGLContextHandle); - d->qGLContextDeleteFunction = 0; - d->qGLContextHandle = 0; + d->qGLContextDeleteFunction = nullptr; + d->qGLContextHandle = nullptr; } } @@ -1252,7 +1252,7 @@ void *QOpenGLContext::openGLModuleHandle() Q_ASSERT(ni); return ni->nativeResourceForIntegration(QByteArrayLiteral("glhandle")); #else - return 0; + return nullptr; #endif } @@ -1438,7 +1438,7 @@ QList QOpenGLContextGroup::shares() const QOpenGLContextGroup *QOpenGLContextGroup::currentContextGroup() { QOpenGLContext *current = QOpenGLContext::currentContext(); - return current ? current->shareGroup() : 0; + return current ? current->shareGroup() : nullptr; } void QOpenGLContextGroupPrivate::addContext(QOpenGLContext *ctx) @@ -1491,7 +1491,7 @@ void QOpenGLContextGroupPrivate::cleanup() while (it != end) { (*it)->invalidateResource(); - (*it)->m_group = 0; + (*it)->m_group = nullptr; ++it; } diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index 022a47c919..2ea8f43711 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -208,8 +208,8 @@ QOpenGLWindowPrivate::~QOpenGLWindowPrivate() Q_Q(QOpenGLWindow); if (q->isValid()) { q->makeCurrent(); // this works even when the platformwindow is destroyed - paintDevice.reset(0); - fbo.reset(0); + paintDevice.reset(nullptr); + fbo.reset(nullptr); blitter.destroy(); q->doneCurrent(); } @@ -692,7 +692,7 @@ QPaintDevice *QOpenGLWindow::redirected(QPoint *) const Q_D(const QOpenGLWindow); if (QOpenGLContext::currentContext() == d->context.data()) return d->paintDevice.data(); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/gui/kernel/qpaintdevicewindow.cpp b/src/gui/kernel/qpaintdevicewindow.cpp index 4521c2f62c..4f45fc5fde 100644 --- a/src/gui/kernel/qpaintdevicewindow.cpp +++ b/src/gui/kernel/qpaintdevicewindow.cpp @@ -219,7 +219,7 @@ QPaintDeviceWindow::QPaintDeviceWindow(QPaintDeviceWindowPrivate &dd, QWindow *p */ QPaintEngine *QPaintDeviceWindow::paintEngine() const { - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 61dccd77ac..fc063bc72c 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -536,7 +536,7 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button) \sa QApplication::setPalette(), QApplication::palette() */ QPalette::QPalette() - : d(0) + : d(nullptr) { data.current_group = Active; data.resolve_mask = 0; diff --git a/src/gui/kernel/qplatformclipboard.cpp b/src/gui/kernel/qplatformclipboard.cpp index ab2998b901..34c94dca3b 100644 --- a/src/gui/kernel/qplatformclipboard.cpp +++ b/src/gui/kernel/qplatformclipboard.cpp @@ -67,7 +67,7 @@ private: QClipboardData::QClipboardData() { - src = 0; + src = nullptr; } QClipboardData::~QClipboardData() diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index 34c4549443..12065078c1 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -128,7 +128,7 @@ void QPlatformCursor::setPos(const QPoint &pos) qWarning("This plugin does not support QCursor::setPos()" "; emulating movement within the application."); } - QWindowSystemInterface::handleMouseEvent(0, pos, pos, Qt::NoButton, Qt::NoButton, QEvent::MouseMove); + QWindowSystemInterface::handleMouseEvent(nullptr, pos, pos, Qt::NoButton, Qt::NoButton, QEvent::MouseMove); } // End of display and pointer event handling code @@ -431,7 +431,7 @@ void QPlatformCursorImage::createSystemCursor(int id) { if (!systemCursorTableInit) { for (int i = 0; i <= Qt::LastCursor; i++) - systemCursorTable[i] = 0; + systemCursorTable[i] = nullptr; systemCursorTableInit = true; } switch (id) { @@ -478,7 +478,7 @@ void QPlatformCursorImage::createSystemCursor(int id) case Qt::BlankCursor: systemCursorTable[Qt::BlankCursor] = - new QPlatformCursorImage(0, 0, 0, 0, 0, 0); + new QPlatformCursorImage(nullptr, nullptr, 0, 0, 0, 0); break; // 20x20 cursors @@ -548,14 +548,14 @@ void QPlatformCursorImage::createSystemCursor(int id) void QPlatformCursorImage::set(Qt::CursorShape id) { - QPlatformCursorImage *cursor = 0; + QPlatformCursorImage *cursor = nullptr; if (unsigned(id) <= unsigned(Qt::LastCursor)) { if (!systemCursorTable[id]) createSystemCursor(id); cursor = systemCursorTable[id]; } - if (cursor == 0) { + if (cursor == nullptr) { if (!systemCursorTable[Qt::ArrowCursor]) createSystemCursor(Qt::ArrowCursor); cursor = systemCursorTable[Qt::ArrowCursor]; diff --git a/src/gui/kernel/qplatforminputcontextfactory.cpp b/src/gui/kernel/qplatforminputcontextfactory.cpp index df7b95d8df..749abaf27a 100644 --- a/src/gui/kernel/qplatforminputcontextfactory.cpp +++ b/src/gui/kernel/qplatforminputcontextfactory.cpp @@ -85,7 +85,7 @@ QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key) #else Q_UNUSED(key); #endif - return 0; + return nullptr; } QPlatformInputContext *QPlatformInputContextFactory::create() diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index b3d3db0751..63f66e6bf7 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE */ QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const { - static QPlatformFontDatabase *db = 0; + static QPlatformFontDatabase *db = nullptr; if (!db) { db = new QPlatformFontDatabase; } @@ -86,7 +86,7 @@ QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const QPlatformClipboard *QPlatformIntegration::clipboard() const { - static QPlatformClipboard *clipboard = 0; + static QPlatformClipboard *clipboard = nullptr; if (!clipboard) { clipboard = new QPlatformClipboard; } @@ -104,7 +104,7 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const */ QPlatformDrag *QPlatformIntegration::drag() const { - static QSimpleDrag *drag = 0; + static QSimpleDrag *drag = nullptr; if (!drag) { drag = new QSimpleDrag; } @@ -114,12 +114,12 @@ QPlatformDrag *QPlatformIntegration::drag() const QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const { - return 0; + return nullptr; } QPlatformServices *QPlatformIntegration::services() const { - return 0; + return nullptr; } /*! @@ -303,7 +303,7 @@ QPlatformOpenGLContext *QPlatformIntegration::createPlatformOpenGLContext(QOpenG { Q_UNUSED(context); qWarning("This plugin does not support createPlatformOpenGLContext!"); - return 0; + return nullptr; } #endif // QT_NO_OPENGL @@ -315,7 +315,7 @@ QPlatformSharedGraphicsCache *QPlatformIntegration::createPlatformSharedGraphics { qWarning("This plugin does not support createPlatformSharedGraphicsBuffer for cacheId: %s!", cacheId); - return 0; + return nullptr; } /*! @@ -325,7 +325,7 @@ QPlatformSharedGraphicsCache *QPlatformIntegration::createPlatformSharedGraphics QPaintEngine *QPlatformIntegration::createImagePaintEngine(QPaintDevice *paintDevice) const { Q_UNUSED(paintDevice) - return 0; + return nullptr; } /*! @@ -357,7 +357,7 @@ void QPlatformIntegration::destroy() */ QPlatformInputContext *QPlatformIntegration::inputContext() const { - return 0; + return nullptr; } #ifndef QT_NO_ACCESSIBILITY @@ -370,7 +370,7 @@ QPlatformInputContext *QPlatformIntegration::inputContext() const */ QPlatformAccessibility *QPlatformIntegration::accessibility() const { - static QPlatformAccessibility *accessibility = 0; + static QPlatformAccessibility *accessibility = nullptr; if (Q_UNLIKELY(!accessibility)) { accessibility = new QPlatformAccessibility; } @@ -484,7 +484,7 @@ class QPlatformTheme *QPlatformIntegration::createPlatformTheme(const QString &n QPlatformOffscreenSurface *QPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const { Q_UNUSED(surface) - return 0; + return nullptr; } #ifndef QT_NO_SESSIONMANAGER diff --git a/src/gui/kernel/qplatformintegrationplugin.cpp b/src/gui/kernel/qplatformintegrationplugin.cpp index 35e4d2797b..b100eacbb5 100644 --- a/src/gui/kernel/qplatformintegrationplugin.cpp +++ b/src/gui/kernel/qplatformintegrationplugin.cpp @@ -54,7 +54,7 @@ QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, con { Q_UNUSED(key) Q_UNUSED(paramList); - return 0; + return nullptr; } QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, const QStringList ¶mList, int &argc, char **argv) diff --git a/src/gui/kernel/qplatformnativeinterface.cpp b/src/gui/kernel/qplatformnativeinterface.cpp index b24541d3ec..8c9e73fbc2 100644 --- a/src/gui/kernel/qplatformnativeinterface.cpp +++ b/src/gui/kernel/qplatformnativeinterface.cpp @@ -56,35 +56,35 @@ QT_BEGIN_NAMESPACE void *QPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } void *QPlatformNativeInterface::nativeResourceForScreen(const QByteArray &resource, QScreen *screen) { Q_UNUSED(resource); Q_UNUSED(screen); - return 0; + return nullptr; } void *QPlatformNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window) { Q_UNUSED(resource); Q_UNUSED(window); - return 0; + return nullptr; } void *QPlatformNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) { Q_UNUSED(resource); Q_UNUSED(context); - return 0; + return nullptr; } void * QPlatformNativeInterface::nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) { Q_UNUSED(resource); Q_UNUSED(backingStore); - return 0; + return nullptr; } #ifndef QT_NO_CURSOR @@ -99,31 +99,31 @@ void *QPlatformNativeInterface::nativeResourceForCursor(const QByteArray &resour QPlatformNativeInterface::NativeResourceForIntegrationFunction QPlatformNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForContextFunction QPlatformNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForScreenFunction QPlatformNativeInterface::nativeResourceFunctionForScreen(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForWindowFunction QPlatformNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForBackingStoreFunction QPlatformNativeInterface::nativeResourceFunctionForBackingStore(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QFunctionPointer QPlatformNativeInterface::platformFunction(const QByteArray &function) const diff --git a/src/gui/kernel/qplatformopenglcontext.cpp b/src/gui/kernel/qplatformopenglcontext.cpp index 07b5a0dda6..839ec008aa 100644 --- a/src/gui/kernel/qplatformopenglcontext.cpp +++ b/src/gui/kernel/qplatformopenglcontext.cpp @@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE class QPlatformOpenGLContextPrivate { public: - QPlatformOpenGLContextPrivate() : context(0) {} + QPlatformOpenGLContextPrivate() : context(nullptr) {} QOpenGLContext *context; }; diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index e511a6f5c4..7c1e2158b1 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -54,7 +54,7 @@ QPlatformScreen::QPlatformScreen() : d_ptr(new QPlatformScreenPrivate) { Q_D(QPlatformScreen); - d->screen = 0; + d->screen = nullptr; } QPlatformScreen::~QPlatformScreen() @@ -99,7 +99,7 @@ QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const return w; } - return 0; + return nullptr; } /*! @@ -310,7 +310,7 @@ QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window // QTBUG 32681: It can happen during the transition between screens // when one screen is disconnected that the window doesn't have a screen. if (!window->screen()) - return 0; + return nullptr; return window->screen()->handle(); } @@ -395,7 +395,7 @@ QString QPlatformScreen::serialNumber() const */ QPlatformCursor *QPlatformScreen::cursor() const { - return 0; + return nullptr; } /*! diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index f906f808d8..71521c0339 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -354,7 +354,7 @@ const uint QPlatformThemePrivate::numberOfKeyBindings = sizeof(QPlatformThemePri #endif QPlatformThemePrivate::QPlatformThemePrivate() - : systemPalette(0) + : systemPalette(nullptr) { } QPlatformThemePrivate::~QPlatformThemePrivate() @@ -394,7 +394,7 @@ bool QPlatformTheme::usePlatformNativeDialog(DialogType type) const QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType type) const { Q_UNUSED(type); - return 0; + return nullptr; } const QPalette *QPlatformTheme::palette(Palette type) const @@ -405,13 +405,13 @@ const QPalette *QPlatformTheme::palette(Palette type) const const_cast(this)->d_ptr->initializeSystemPalette(); return d->systemPalette; } - return 0; + return nullptr; } const QFont *QPlatformTheme::font(Font type) const { Q_UNUSED(type) - return 0; + return nullptr; } QPixmap QPlatformTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const @@ -569,17 +569,17 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) QPlatformMenuItem *QPlatformTheme::createPlatformMenuItem() const { - return 0; + return nullptr; } QPlatformMenu *QPlatformTheme::createPlatformMenu() const { - return 0; + return nullptr; } QPlatformMenuBar *QPlatformTheme::createPlatformMenuBar() const { - return 0; + return nullptr; } #ifndef QT_NO_SYSTEMTRAYICON @@ -589,7 +589,7 @@ QPlatformMenuBar *QPlatformTheme::createPlatformMenuBar() const */ QPlatformSystemTrayIcon *QPlatformTheme::createPlatformSystemTrayIcon() const { - return 0; + return nullptr; } #endif diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 80de561297..9de59f8c7e 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE */ QScreen::QScreen(QPlatformScreen *screen) - : QObject(*new QScreenPrivate(), 0) + : QObject(*new QScreenPrivate(), nullptr) { Q_D(QScreen); d->setPlatformScreen(screen); diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp index e5e9c624b2..8747e02719 100644 --- a/src/gui/kernel/qsessionmanager.cpp +++ b/src/gui/kernel/qsessionmanager.cpp @@ -135,7 +135,7 @@ QSessionManagerPrivate::QSessionManagerPrivate(const QString &id, QSessionManagerPrivate::~QSessionManagerPrivate() { delete platformSessionManager; - platformSessionManager = 0; + platformSessionManager = nullptr; } QSessionManager::QSessionManager(QGuiApplication *app, QString &id, QString &key) diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 9ed450b031..a7ea20266b 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -65,11 +65,11 @@ Q_LOGGING_CATEGORY(lcShortcutMap, "qt.gui.shortcutmap") struct QShortcutEntry { QShortcutEntry() - : keyseq(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0), contextMatcher(0) + : keyseq(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(nullptr), contextMatcher(nullptr) {} QShortcutEntry(const QKeySequence &k) - : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0), contextMatcher(0) + : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(nullptr), contextMatcher(nullptr) {} QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i, bool a, QShortcutMap::ContextMatcher m) @@ -184,7 +184,7 @@ int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key { Q_D(QShortcutMap); int itemsRemoved = 0; - bool allOwners = (owner == 0); + bool allOwners = (owner == nullptr); bool allKeys = key.isEmpty(); bool allIds = id == 0; @@ -228,7 +228,7 @@ int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const { Q_D(QShortcutMap); int itemsChanged = 0; - bool allOwners = (owner == 0); + bool allOwners = (owner == nullptr); bool allKeys = key.isEmpty(); bool allIds = id == 0; @@ -264,7 +264,7 @@ int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const Q { Q_D(QShortcutMap); int itemsChanged = 0; - bool allOwners = (owner == 0); + bool allOwners = (owner == nullptr); bool allKeys = key.isEmpty(); bool allIds = id == 0; @@ -638,7 +638,7 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e) d->prevSequence = curKey; } // Find next - const QShortcutEntry *current = 0, *next = 0; + const QShortcutEntry *current = nullptr, *next = nullptr; int i = 0, enabledShortcuts = 0; QVector ambiguousShortcuts; while(i < d->identicals.size()) { diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 803206477c..dec3cc399d 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -76,7 +76,7 @@ static QWindow* topLevelAt(const QPoint &pos) if (w->isVisible() && w->handle() && w->geometry().contains(pos) && !qobject_cast(w)) return w; } - return 0; + return nullptr; } /*! diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 732ede90d0..7b3c70c51b 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -116,7 +116,7 @@ public: \sa QGuiApplication::styleHints() */ QStyleHints::QStyleHints() - : QObject(*new QStyleHintsPrivate(), 0) + : QObject(*new QStyleHintsPrivate(), nullptr) { } diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp index 709f28d431..85c576b21c 100644 --- a/src/gui/kernel/qsurface.cpp +++ b/src/gui/kernel/qsurface.cpp @@ -134,7 +134,7 @@ bool QSurface::supportsOpenGL() const Creates a surface with the given \a type. */ QSurface::QSurface(SurfaceClass type) - : m_type(type), m_reserved(0) + : m_type(type), m_reserved(nullptr) { } diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b71a0c54aa..74e0e6401e 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -156,7 +156,7 @@ QT_BEGIN_NAMESPACE \sa setScreen() */ QWindow::QWindow(QScreen *targetScreen) - : QObject(*new QWindowPrivate(), 0) + : QObject(*new QWindowPrivate(), nullptr) , QSurface(QSurface::Window) { Q_D(QWindow); @@ -223,7 +223,7 @@ QWindow::~QWindow() // some cases end up becoming the focus window again. Clear it again // here as a workaround. See QTBUG-75326. if (QGuiApplicationPrivate::focus_window == this) - QGuiApplicationPrivate::focus_window = 0; + QGuiApplicationPrivate::focus_window = nullptr; } void QWindowPrivate::init(QScreen *targetScreen) @@ -469,7 +469,7 @@ inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const inline void QWindowPrivate::disconnectFromScreen() { if (topLevelScreen) - topLevelScreen = 0; + topLevelScreen = nullptr; } void QWindowPrivate::connectToScreen(QScreen *screen) @@ -732,7 +732,7 @@ void QWindow::setParent(QWindow *parent) if (parent) parent->create(); - d->platformWindow->setParent(parent ? parent->d_func()->platformWindow : 0); + d->platformWindow->setParent(parent ? parent->d_func()->platformWindow : nullptr); } QGuiApplicationPrivate::updateBlockedStatus(this); @@ -744,7 +744,7 @@ void QWindow::setParent(QWindow *parent) bool QWindow::isTopLevel() const { Q_D(const QWindow); - return d->parentWindow == 0; + return d->parentWindow == nullptr; } /*! @@ -2018,7 +2018,7 @@ void QWindow::setScreen(QScreen *newScreen) Q_D(QWindow); if (!newScreen) newScreen = QGuiApplication::primaryScreen(); - d->setTopLevelScreen(newScreen, newScreen != 0); + d->setTopLevelScreen(newScreen, newScreen != nullptr); } /*! @@ -2036,7 +2036,7 @@ void QWindow::setScreen(QScreen *newScreen) */ QAccessibleInterface *QWindow::accessibleRoot() const { - return 0; + return nullptr; } /*! @@ -2696,7 +2696,7 @@ QWindow *QWindow::fromWinId(WId id) { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ForeignWindows)) { qWarning("QWindow::fromWinId(): platform plugin does not support foreign windows."); - return 0; + return nullptr; } QWindow *window = new QWindow; @@ -2770,7 +2770,7 @@ void QWindow::setCursor(const QCursor &cursor) void QWindow::unsetCursor() { Q_D(QWindow); - d->setCursor(0); + d->setCursor(nullptr); } /*! diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index ba04f8701d..c9a70897d6 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -179,7 +179,7 @@ void QWindowSystemInterfacePrivate::installWindowSystemEventHandler(QWindowSyste void QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(QWindowSystemEventHandler *handler) { if (eventHandler == handler) - eventHandler = 0; + eventHandler = nullptr; } QWindowSystemEventHandler::~QWindowSystemEventHandler() diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 667d16317f..adca536797 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -72,7 +72,7 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() return; } QOpenGLFunctions *funcs = ctx->functions(); - const char *extensionStr = 0; + const char *extensionStr = nullptr; if (ctx->isOpenGLES() || ctx->format().majorVersion() < 3) extensionStr = reinterpret_cast(funcs->glGetString(GL_EXTENSIONS)); diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp index 5ad16a8438..5387cc06e3 100644 --- a/src/gui/opengl/qopenglbuffer.cpp +++ b/src/gui/opengl/qopenglbuffer.cpp @@ -143,10 +143,10 @@ public: QOpenGLBufferPrivate(QOpenGLBuffer::Type t) : ref(1), type(t), - guard(0), + guard(nullptr), usagePattern(QOpenGLBuffer::StaticDraw), actualUsagePattern(QOpenGLBuffer::StaticDraw), - funcs(0) + funcs(nullptr) { } @@ -323,10 +323,10 @@ void QOpenGLBuffer::destroy() Q_D(QOpenGLBuffer); if (d->guard) { d->guard->free(); - d->guard = 0; + d->guard = nullptr; } delete d->funcs; - d->funcs = 0; + d->funcs = nullptr; } /*! @@ -586,7 +586,7 @@ void *QOpenGLBuffer::mapRange(int offset, int count, QOpenGLBuffer::RangeAccessF qWarning("QOpenGLBuffer::mapRange(): buffer not created"); #endif if (!d->guard || !d->guard->id()) - return 0; + return nullptr; return d->funcs->glMapBufferRange(d->type, offset, count, access); } diff --git a/src/gui/opengl/qopenglcustomshaderstage.cpp b/src/gui/opengl/qopenglcustomshaderstage.cpp index baa44f86b0..a95a0a5767 100644 --- a/src/gui/opengl/qopenglcustomshaderstage.cpp +++ b/src/gui/opengl/qopenglcustomshaderstage.cpp @@ -48,7 +48,7 @@ class QOpenGLCustomShaderStagePrivate { public: QOpenGLCustomShaderStagePrivate() : - m_manager(0) {} + m_manager(nullptr) {} QPointer m_manager; QByteArray m_source; @@ -110,8 +110,8 @@ void QOpenGLCustomShaderStage::removeFromPainter(QPainter* p) // Just set the stage to null, don't call removeCustomStage(). // This should leave the program in a compiled/linked state // if the next custom shader stage is this one again. - d->m_manager->setCustomStage(0); - d->m_manager = 0; + d->m_manager->setCustomStage(nullptr); + d->m_manager = nullptr; } QByteArray QOpenGLCustomShaderStage::source() const @@ -125,7 +125,7 @@ QByteArray QOpenGLCustomShaderStage::source() const void QOpenGLCustomShaderStage::setInactive() { Q_D(QOpenGLCustomShaderStage); - d->m_manager = 0; + d->m_manager = nullptr; } void QOpenGLCustomShaderStage::setSource(const QByteArray& s) diff --git a/src/gui/opengl/qopengldebug.cpp b/src/gui/opengl/qopengldebug.cpp index 462a4fdb3b..310006feaf 100644 --- a/src/gui/opengl/qopengldebug.cpp +++ b/src/gui/opengl/qopengldebug.cpp @@ -1108,14 +1108,14 @@ public: \internal */ QOpenGLDebugLoggerPrivate::QOpenGLDebugLoggerPrivate() - : glDebugMessageControl(0), - glDebugMessageInsert(0), - glDebugMessageCallback(0), - glGetDebugMessageLog(0), - glPushDebugGroup(0), - glPopDebugGroup(0), - oldDebugCallbackFunction(0), - context(0), + : glDebugMessageControl(nullptr), + glDebugMessageInsert(nullptr), + glDebugMessageCallback(nullptr), + glGetDebugMessageLog(nullptr), + glPushDebugGroup(nullptr), + glPopDebugGroup(nullptr), + oldDebugCallbackFunction(nullptr), + context(nullptr), maxMessageLength(0), loggingMode(QOpenGLDebugLogger::AsynchronousLogging), initialized(false), @@ -1228,7 +1228,7 @@ void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Source const GLsizei idCount = ids.count(); // The GL_KHR_debug extension says that if idCount is 0, idPtr must be ignored. // Unfortunately, some bugged drivers do NOT ignore it, so pass NULL in case. - const GLuint * const idPtr = idCount ? ids.constData() : 0; + const GLuint * const idPtr = idCount ? ids.constData() : nullptr; for (GLenum source : glSources) for (GLenum type : glTypes) @@ -1247,7 +1247,7 @@ void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed() // Save the current context and its surface in case we need to set them back QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - QSurface *currentSurface = 0; + QSurface *currentSurface = nullptr; QScopedPointer offscreenSurface; @@ -1275,7 +1275,7 @@ void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed() } QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); - context = 0; + context = nullptr; initialized = false; } @@ -1356,7 +1356,7 @@ bool QOpenGLDebugLogger::initialize() disconnect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed())); d->initialized = false; - d->context = 0; + d->context = nullptr; if (!context->hasExtension(QByteArrayLiteral("GL_KHR_debug"))) return false; diff --git a/src/gui/opengl/qopenglengineshadermanager.cpp b/src/gui/opengl/qopenglengineshadermanager.cpp index 1e5a10c99c..a569975486 100644 --- a/src/gui/opengl/qopenglengineshadermanager.cpp +++ b/src/gui/opengl/qopenglengineshadermanager.cpp @@ -72,7 +72,7 @@ public: void invalidateResource() override { delete m_shaders; - m_shaders = 0; + m_shaders = nullptr; } void freeResource(QOpenGLContext *) override @@ -94,7 +94,7 @@ public: shaders = new QOpenGLMultiGroupSharedResource; QOpenGLEngineSharedShadersResource *resource = shaders->value(context); - return resource ? resource->shaders() : 0; + return resource ? resource->shaders() : nullptr; } private: @@ -116,8 +116,8 @@ const char* QOpenGLEngineSharedShaders::qShaderSnippets[] = { }; QOpenGLEngineSharedShaders::QOpenGLEngineSharedShaders(QOpenGLContext* context) - : blitShaderProg(0) - , simpleShaderProg(0) + : blitShaderProg(nullptr) + , simpleShaderProg(nullptr) { /* @@ -341,12 +341,12 @@ QOpenGLEngineSharedShaders::~QOpenGLEngineSharedShaders() if (blitShaderProg) { delete blitShaderProg; - blitShaderProg = 0; + blitShaderProg = nullptr; } if (simpleShaderProg) { delete simpleShaderProg; - simpleShaderProg = 0; + simpleShaderProg = nullptr; } } @@ -507,8 +507,8 @@ QOpenGLEngineShaderManager::QOpenGLEngineShaderManager(QOpenGLContext* context) opacityMode(NoOpacity), maskType(NoMask), compositionMode(QPainter::CompositionMode_SourceOver), - customSrcStage(0), - currentShaderProg(0) + customSrcStage(nullptr), + currentShaderProg(nullptr) { sharedShaders = QOpenGLEngineSharedShaders::shadersForContext(context); } @@ -627,7 +627,7 @@ void QOpenGLEngineShaderManager::removeCustomStage() { if (customSrcStage) customSrcStage->setInactive(); - customSrcStage = 0; + customSrcStage = nullptr; shaderProgNeedsChanging = true; } @@ -684,7 +684,7 @@ bool QOpenGLEngineShaderManager::useCorrectShaderProg() if (!shaderProgNeedsChanging) return false; - bool useCustomSrc = customSrcStage != 0; + bool useCustomSrc = customSrcStage != nullptr; if (useCustomSrc && srcPixelType != QOpenGLEngineShaderManager::ImageSrc && srcPixelType != Qt::TexturePattern) { useCustomSrc = false; qWarning("QOpenGLEngineShaderManager - Ignoring custom shader stage for non image src"); diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index bb0dbdc9bd..d7a6d32218 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -551,7 +551,7 @@ void QOpenGLFramebufferObjectPrivate::initTexture(int idx) pixelType = GL_UNSIGNED_SHORT; funcs.glTexImage2D(target, 0, color.internalFormat, color.size.width(), color.size.height(), 0, - GL_RGBA, pixelType, NULL); + GL_RGBA, pixelType, nullptr); if (format.mipmap()) { int width = color.size.width(); int height = color.size.height(); @@ -561,7 +561,7 @@ void QOpenGLFramebufferObjectPrivate::initTexture(int idx) height = qMax(1, height >> 1); ++level; funcs.glTexImage2D(target, level, color.internalFormat, width, height, 0, - GL_RGBA, pixelType, NULL); + GL_RGBA, pixelType, nullptr); } } funcs.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + idx, @@ -640,8 +640,8 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext stencil_buffer_guard->free(); } - depth_buffer_guard = 0; - stencil_buffer_guard = 0; + depth_buffer_guard = nullptr; + stencil_buffer_guard = nullptr; GLuint depth_buffer = 0; GLuint stencil_buffer = 0; @@ -1284,7 +1284,7 @@ GLuint QOpenGLFramebufferObject::takeTexture(int colorAttachmentIndex) id = guard ? guard->id() : 0; // Do not call free() on texture_guard, just null it out. // This way the texture will not be deleted when the guard is destroyed. - guard = 0; + guard = nullptr; } return id; } @@ -1564,7 +1564,7 @@ bool QOpenGLFramebufferObject::bindDefault() qWarning("QOpenGLFramebufferObject::bindDefault() called without current context."); #endif - return ctx != 0; + return ctx != nullptr; } /*! diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 3e9eb3dd0a..11ca802ee6 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -182,7 +182,7 @@ struct QOpenGLFunctionsPrivateEx : public QOpenGLExtensionsPrivate, public QOpen Q_GLOBAL_STATIC(QOpenGLMultiGroupSharedResource, qt_gl_functions_resource) -static QOpenGLFunctionsPrivateEx *qt_gl_functions(QOpenGLContext *context = 0) +static QOpenGLFunctionsPrivateEx *qt_gl_functions(QOpenGLContext *context = nullptr) { if (!context) context = QOpenGLContext::currentContext(); @@ -200,7 +200,7 @@ static QOpenGLFunctionsPrivateEx *qt_gl_functions(QOpenGLContext *context = 0) \sa initializeOpenGLFunctions() */ QOpenGLFunctions::QOpenGLFunctions() - : d_ptr(0) + : d_ptr(nullptr) { } @@ -218,7 +218,7 @@ QOpenGLFunctions::QOpenGLFunctions() \sa initializeOpenGLFunctions() */ QOpenGLFunctions::QOpenGLFunctions(QOpenGLContext *context) - : d_ptr(0) + : d_ptr(nullptr) { if (context && QOpenGLContextGroup::currentContextGroup() == context->shareGroup()) d_ptr = qt_gl_functions(context); diff --git a/src/gui/opengl/qopenglfunctions_1_0.cpp b/src/gui/opengl/qopenglfunctions_1_0.cpp index f017c68fd9..f9d93ce210 100644 --- a/src/gui/opengl/qopenglfunctions_1_0.cpp +++ b/src/gui/opengl/qopenglfunctions_1_0.cpp @@ -67,8 +67,8 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_0::QOpenGLFunctions_1_0() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_0_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_0_Deprecated(nullptr) { } @@ -98,7 +98,7 @@ bool QOpenGLFunctions_1_0::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_1.cpp b/src/gui/opengl/qopenglfunctions_1_1.cpp index a819d499f8..b0f7538d48 100644 --- a/src/gui/opengl/qopenglfunctions_1_1.cpp +++ b/src/gui/opengl/qopenglfunctions_1_1.cpp @@ -67,10 +67,10 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_1::QOpenGLFunctions_1_1() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) { } @@ -108,7 +108,7 @@ bool QOpenGLFunctions_1_1::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_2.cpp b/src/gui/opengl/qopenglfunctions_1_2.cpp index 61db2b4e0f..5f137b0237 100644 --- a/src/gui/opengl/qopenglfunctions_1_2.cpp +++ b/src/gui/opengl/qopenglfunctions_1_2.cpp @@ -67,12 +67,12 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_2::QOpenGLFunctions_1_2() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) { } @@ -118,7 +118,7 @@ bool QOpenGLFunctions_1_2::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_3.cpp b/src/gui/opengl/qopenglfunctions_1_3.cpp index acc223ea74..0b5ff2fee5 100644 --- a/src/gui/opengl/qopenglfunctions_1_3.cpp +++ b/src/gui/opengl/qopenglfunctions_1_3.cpp @@ -67,14 +67,14 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_3::QOpenGLFunctions_1_3() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) { } @@ -128,7 +128,7 @@ bool QOpenGLFunctions_1_3::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_4.cpp b/src/gui/opengl/qopenglfunctions_1_4.cpp index 8e2349dc08..9419c1aa85 100644 --- a/src/gui/opengl/qopenglfunctions_1_4.cpp +++ b/src/gui/opengl/qopenglfunctions_1_4.cpp @@ -67,16 +67,16 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_4::QOpenGLFunctions_1_4() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) { } @@ -138,7 +138,7 @@ bool QOpenGLFunctions_1_4::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_5.cpp b/src/gui/opengl/qopenglfunctions_1_5.cpp index cd81cf8b35..3fa7668a36 100644 --- a/src/gui/opengl/qopenglfunctions_1_5.cpp +++ b/src/gui/opengl/qopenglfunctions_1_5.cpp @@ -67,17 +67,17 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_5::QOpenGLFunctions_1_5() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) { } @@ -143,7 +143,7 @@ bool QOpenGLFunctions_1_5::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_2_0.cpp b/src/gui/opengl/qopenglfunctions_2_0.cpp index 97a8c72fa6..29eb055a1d 100644 --- a/src/gui/opengl/qopenglfunctions_2_0.cpp +++ b/src/gui/opengl/qopenglfunctions_2_0.cpp @@ -67,18 +67,18 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_2_0::QOpenGLFunctions_2_0() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) { } @@ -149,7 +149,7 @@ bool QOpenGLFunctions_2_0::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_2_1.cpp b/src/gui/opengl/qopenglfunctions_2_1.cpp index 00bdc1bbba..8a7170dd7d 100644 --- a/src/gui/opengl/qopenglfunctions_2_1.cpp +++ b/src/gui/opengl/qopenglfunctions_2_1.cpp @@ -67,19 +67,19 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_2_1::QOpenGLFunctions_2_1() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) { } @@ -154,7 +154,7 @@ bool QOpenGLFunctions_2_1::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_0.cpp b/src/gui/opengl/qopenglfunctions_3_0.cpp index 2c239dba1f..7d0e900659 100644 --- a/src/gui/opengl/qopenglfunctions_3_0.cpp +++ b/src/gui/opengl/qopenglfunctions_3_0.cpp @@ -67,20 +67,20 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_0::QOpenGLFunctions_3_0() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) , m_reserved_3_0_Deprecated(nullptr) { @@ -160,7 +160,7 @@ bool QOpenGLFunctions_3_0::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_1.cpp b/src/gui/opengl/qopenglfunctions_3_1.cpp index f62f555c8e..c25b124af8 100644 --- a/src/gui/opengl/qopenglfunctions_3_1.cpp +++ b/src/gui/opengl/qopenglfunctions_3_1.cpp @@ -67,16 +67,16 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_1::QOpenGLFunctions_3_1() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) { } @@ -138,7 +138,7 @@ bool QOpenGLFunctions_3_1::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp b/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp index ba7be2d893..3e4fd96dc2 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp @@ -67,22 +67,22 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_2_Compatibility::QOpenGLFunctions_3_2_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) , m_reserved_3_0_Deprecated(nullptr) { @@ -170,7 +170,7 @@ bool QOpenGLFunctions_3_2_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_2_core.cpp b/src/gui/opengl/qopenglfunctions_3_2_core.cpp index 4c1e3eb3da..ea89fc9e48 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_core.cpp +++ b/src/gui/opengl/qopenglfunctions_3_2_core.cpp @@ -67,17 +67,17 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_2_Core::QOpenGLFunctions_3_2_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) { } @@ -143,7 +143,7 @@ bool QOpenGLFunctions_3_2_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp b/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp index c750c6e0cc..a26d7d99b1 100644 --- a/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp @@ -67,25 +67,25 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_3_Compatibility::QOpenGLFunctions_3_3_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -179,7 +179,7 @@ bool QOpenGLFunctions_3_3_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_3_core.cpp b/src/gui/opengl/qopenglfunctions_3_3_core.cpp index 5723509e32..277ad1eb14 100644 --- a/src/gui/opengl/qopenglfunctions_3_3_core.cpp +++ b/src/gui/opengl/qopenglfunctions_3_3_core.cpp @@ -67,18 +67,18 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_3_Core::QOpenGLFunctions_3_3_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) { } @@ -148,7 +148,7 @@ bool QOpenGLFunctions_3_3_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp index 6ae7643eb5..655f1e6fd4 100644 --- a/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp @@ -67,26 +67,26 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_0_Compatibility::QOpenGLFunctions_4_0_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -184,7 +184,7 @@ bool QOpenGLFunctions_4_0_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_0_core.cpp b/src/gui/opengl/qopenglfunctions_4_0_core.cpp index cd4fdb8b2b..60453d147c 100644 --- a/src/gui/opengl/qopenglfunctions_4_0_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_0_core.cpp @@ -67,19 +67,19 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_0_Core::QOpenGLFunctions_4_0_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) { } @@ -153,7 +153,7 @@ bool QOpenGLFunctions_4_0_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp index d104c74bc2..bdea8b5ba9 100644 --- a/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp @@ -67,27 +67,27 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_1_Compatibility::QOpenGLFunctions_4_1_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -189,7 +189,7 @@ bool QOpenGLFunctions_4_1_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_1_core.cpp b/src/gui/opengl/qopenglfunctions_4_1_core.cpp index 7527aba620..b21742d9c1 100644 --- a/src/gui/opengl/qopenglfunctions_4_1_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_1_core.cpp @@ -67,20 +67,20 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_1_Core::QOpenGLFunctions_4_1_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) { } @@ -158,7 +158,7 @@ bool QOpenGLFunctions_4_1_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp index a5b1b37495..41ab9ae762 100644 --- a/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp @@ -67,28 +67,28 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_2_Compatibility::QOpenGLFunctions_4_2_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -194,7 +194,7 @@ bool QOpenGLFunctions_4_2_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_2_core.cpp b/src/gui/opengl/qopenglfunctions_4_2_core.cpp index 1381236926..38dbe1b596 100644 --- a/src/gui/opengl/qopenglfunctions_4_2_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_2_core.cpp @@ -67,21 +67,21 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_2_Core::QOpenGLFunctions_4_2_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) { } @@ -163,7 +163,7 @@ bool QOpenGLFunctions_4_2_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp index 5c0c711d1c..1b23d08ee2 100644 --- a/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp @@ -67,29 +67,29 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_3_Compatibility::QOpenGLFunctions_4_3_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -199,7 +199,7 @@ bool QOpenGLFunctions_4_3_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_3_core.cpp b/src/gui/opengl/qopenglfunctions_4_3_core.cpp index 34460b841e..8a867471b8 100644 --- a/src/gui/opengl/qopenglfunctions_4_3_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_3_core.cpp @@ -67,22 +67,22 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_3_Core::QOpenGLFunctions_4_3_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) { } @@ -168,7 +168,7 @@ bool QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp index 907994a3c4..4fc4b50100 100644 --- a/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp @@ -67,29 +67,29 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_4_Compatibility::QOpenGLFunctions_4_4_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_4_4_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) - , d_3_3_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_4_4_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) + , d_3_3_Deprecated(nullptr) { } @@ -203,7 +203,7 @@ bool QOpenGLFunctions_4_4_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_4_core.cpp b/src/gui/opengl/qopenglfunctions_4_4_core.cpp index 76c0323f6d..6169c7f455 100644 --- a/src/gui/opengl/qopenglfunctions_4_4_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_4_core.cpp @@ -67,23 +67,23 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_4_Core::QOpenGLFunctions_4_4_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_4_4_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_4_4_Core(nullptr) { } @@ -173,7 +173,7 @@ bool QOpenGLFunctions_4_4_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp index c415bb06ff..02af443498 100644 --- a/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp @@ -67,31 +67,31 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_5_Compatibility::QOpenGLFunctions_4_5_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_4_4_Core(0) - , d_4_5_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) - , d_3_3_Deprecated(0) - , d_4_5_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_4_4_Core(nullptr) + , d_4_5_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) + , d_3_3_Deprecated(nullptr) + , d_4_5_Deprecated(nullptr) { } @@ -213,7 +213,7 @@ bool QOpenGLFunctions_4_5_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_5_core.cpp b/src/gui/opengl/qopenglfunctions_4_5_core.cpp index 4dfac3579c..9c0369e5f2 100644 --- a/src/gui/opengl/qopenglfunctions_4_5_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_5_core.cpp @@ -67,24 +67,24 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_5_Core::QOpenGLFunctions_4_5_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_4_4_Core(0) - , d_4_5_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_4_4_Core(nullptr) + , d_4_5_Core(nullptr) { } @@ -178,7 +178,7 @@ bool QOpenGLFunctions_4_5_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index 3a0c02feb0..3920a10467 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -171,7 +171,7 @@ QOpenGLPaintDevicePrivate::QOpenGLPaintDevicePrivate(const QSize &sz) , dpmy(qt_defaultDpiY() * 100. / 2.54) , devicePixelRatio(1.0) , flipped(false) - , engine(0) + , engine(nullptr) { } diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 20cc2b5ae5..a82edbb073 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -881,7 +881,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path) Q_ASSERT(cache->ibo == 0); #else free(cache->vertices); - Q_ASSERT(cache->indices == 0); + Q_ASSERT(cache->indices == nullptr); #endif updateCache = true; } @@ -909,7 +909,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path) #else cache->vertices = (float *) malloc(floatSizeInBytes); memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes); - cache->indices = 0; + cache->indices = nullptr; #endif } @@ -1359,7 +1359,7 @@ void QOpenGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) return; QOpenGL2PaintEngineState *s = state(); - if (qt_pen_is_cosmetic(pen, state()->renderHints) && !qt_scaleForTransform(s->transform(), 0)) { + if (qt_pen_is_cosmetic(pen, state()->renderHints) && !qt_scaleForTransform(s->transform(), nullptr)) { // QTriangulatingStroker class is not meant to support cosmetically sheared strokes. QPaintEngineEx::stroke(path, pen); return; @@ -1427,7 +1427,7 @@ void QOpenGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &p QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra); fillStencilWithVertexArray(stroker.vertices(), stroker.vertexCount() / 2, - 0, 0, bounds, QOpenGL2PaintEngineExPrivate::TriStripStrokeFillMode); + nullptr, 0, bounds, QOpenGL2PaintEngineExPrivate::TriStripStrokeFillMode); funcs.glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); @@ -1772,7 +1772,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly QOpenGLTextureGlyphCache *cache = (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphFormat, glyphCacheTransform); - if (!cache || cache->glyphFormat() != glyphFormat || cache->contextGroup() == 0) { + if (!cache || cache->glyphFormat() != glyphFormat || cache->contextGroup() == nullptr) { cache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform); fe->setGlyphCache(cacheKey, cache); recreateVertexArrays = true; @@ -1780,7 +1780,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly if (staticTextItem->userDataNeedsUpdate) { recreateVertexArrays = true; - } else if (staticTextItem->userData() == 0) { + } else if (staticTextItem->userData() == nullptr) { recreateVertexArrays = true; } else if (staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) { recreateVertexArrays = true; @@ -1845,9 +1845,9 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly QOpenGL2PEXVertexArray *textureCoordinates = &textureCoordinateArray; if (staticTextItem->useBackendOptimizations) { - QOpenGLStaticTextUserData *userData = 0; + QOpenGLStaticTextUserData *userData = nullptr; - if (staticTextItem->userData() == 0 + if (staticTextItem->userData() == nullptr || staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) { userData = new QOpenGLStaticTextUserData(); @@ -2273,12 +2273,12 @@ bool QOpenGL2PaintEngineEx::end() d->funcs.glUseProgram(0); d->transferMode(BrushDrawingMode); - ctx->d_func()->active_engine = 0; + ctx->d_func()->active_engine = nullptr; d->resetGLState(); delete d->shaderManager; - d->shaderManager = 0; + d->shaderManager = nullptr; d->currentBrush = QBrush(); #ifdef QT_OPENGL_CACHE_AS_VBOS diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 4986ca573d..7e89d9c8d4 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -249,7 +249,7 @@ class QOpenGLShaderPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QOpenGLShader) public: QOpenGLShaderPrivate(QOpenGLContext *ctx, QOpenGLShader::ShaderType type) - : shaderGuard(0) + : shaderGuard(nullptr) , shaderType(type) , compiled(false) , glfuncs(new QOpenGLExtraFunctions(ctx)) @@ -374,8 +374,8 @@ bool QOpenGLShaderPrivate::compile(QOpenGLShader *q) // Get info and source code lengths GLint infoLogLength = 0; GLint sourceCodeLength = 0; - char *logBuffer = 0; - char *sourceCodeBuffer = 0; + char *logBuffer = nullptr; + char *sourceCodeBuffer = nullptr; // Get the compilation info log glfuncs->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); @@ -425,7 +425,7 @@ void QOpenGLShaderPrivate::deleteShader() { if (shaderGuard) { shaderGuard->free(); - shaderGuard = 0; + shaderGuard = nullptr; } } @@ -783,13 +783,13 @@ class QOpenGLShaderProgramPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QOpenGLShaderProgram) public: QOpenGLShaderProgramPrivate() - : programGuard(0) + : programGuard(nullptr) , linked(false) , inited(false) , removingShaders(false) , glfuncs(new QOpenGLExtraFunctions) #ifndef QT_OPENGL_ES_2 - , tessellationFuncs(0) + , tessellationFuncs(nullptr) #endif , linkBinaryRecursion(false) { diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 61a6202017..cf4a8dee8d 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QOpenGLTexturePrivate::QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarget, QOpenGLTexture *qq) : q_ptr(qq), - context(0), + context(nullptr), target(textureTarget), textureId(0), format(QOpenGLTexture::NoFormat), @@ -82,8 +82,8 @@ QOpenGLTexturePrivate::QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarge textureView(false), autoGenerateMipMaps(true), storageAllocated(false), - texFuncs(0), - functions(0) + texFuncs(nullptr), + functions(nullptr) { dimensions[0] = dimensions[1] = dimensions[2] = 1; @@ -208,8 +208,8 @@ void QOpenGLTexturePrivate::destroy() functions->glDeleteTextures(1, &textureId); - context = 0; - functions = 0; + context = nullptr; + functions = nullptr; textureId = 0; format = QOpenGLTexture::NoFormat; formatClass = QOpenGLTexture::NoFormatClass; @@ -231,7 +231,7 @@ void QOpenGLTexturePrivate::destroy() textureView = false; autoGenerateMipMaps = true; storageAllocated = false; - texFuncs = 0; + texFuncs = nullptr; swizzleMask[0] = QOpenGLTexture::RedValue; swizzleMask[1] = QOpenGLTexture::GreenValue; @@ -1141,7 +1141,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p texFuncs->glTextureImage1D(textureId, target, bindingTarget, level, format, mipLevelSize(level, dimensions[0]), 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("1D textures are not supported"); return; @@ -1156,7 +1156,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[0]), layers, 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("1D array textures are not supported"); return; @@ -1170,7 +1170,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[0]), mipLevelSize(level, dimensions[1]), 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); break; case QOpenGLTexture::TargetCubeMap: { @@ -1190,7 +1190,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[0]), mipLevelSize(level, dimensions[1]), 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } } break; @@ -1204,7 +1204,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[1]), layers, 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("Array textures are not supported"); return; @@ -1220,7 +1220,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[1]), 6 * layers, 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("Cubemap Array textures are not supported"); return; @@ -1235,7 +1235,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[1]), mipLevelSize(level, dimensions[2]), 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("3D textures are not supported"); return; @@ -1924,7 +1924,7 @@ QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target if (!viewTargetCompatible) { qWarning("QOpenGLTexture::createTextureView(): Incompatible source and view targets"); - return 0; + return nullptr; } // Check the formats are compatible @@ -2057,7 +2057,7 @@ QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target if (!viewFormatCompatible) { qWarning("QOpenGLTexture::createTextureView(): Incompatible source and view formats"); - return 0; + return nullptr; } @@ -3387,7 +3387,7 @@ QOpenGLTexture *QOpenGLTexture::createTextureView(Target target, Q_D(const QOpenGLTexture); if (!isStorageAllocated()) { qWarning("Cannot set create a texture view of a texture that does not have storage allocated."); - return 0; + return nullptr; } Q_ASSERT(maximumMipmapLevel >= minimumMipmapLevel); Q_ASSERT(maximumLayer >= minimumLayer); diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp index 490dc99749..41027d26e0 100644 --- a/src/gui/opengl/qopengltextureglyphcache.cpp +++ b/src/gui/opengl/qopengltextureglyphcache.cpp @@ -55,9 +55,9 @@ static int next_qopengltextureglyphcache_serial_number() QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix, const QColor &color) : QImageTextureGlyphCache(format, matrix, color) - , m_textureResource(0) - , pex(0) - , m_blitProgram(0) + , m_textureResource(nullptr) + , pex(nullptr) + , m_blitProgram(nullptr) , m_filterMode(Nearest) , m_serialNumber(next_qopengltextureglyphcache_serial_number()) , m_buffer(QOpenGLBuffer::VertexBuffer) @@ -102,7 +102,7 @@ static inline bool isCoreProfile() void QOpenGLTextureGlyphCache::createTextureData(int width, int height) { QOpenGLContext *ctx = const_cast(QOpenGLContext::currentContext()); - if (ctx == 0) { + if (ctx == nullptr) { qWarning("QOpenGLTextureGlyphCache::createTextureData: Called with no context"); return; } @@ -121,7 +121,7 @@ void QOpenGLTextureGlyphCache::createTextureData(int width, int height) if (m_textureResource && !m_textureResource->m_texture) { delete m_textureResource; - m_textureResource = 0; + m_textureResource = nullptr; } if (!m_textureResource) @@ -276,7 +276,7 @@ static void load_glyph_image_region_to_texture(QOpenGLContext *ctx, void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) { QOpenGLContext *ctx = QOpenGLContext::currentContext(); - if (ctx == 0) { + if (ctx == nullptr) { qWarning("QOpenGLTextureGlyphCache::resizeTextureData: Called with no context"); return; } @@ -313,7 +313,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) funcs->glGenTextures(1, &tmp_texture); funcs->glBindTexture(GL_TEXTURE_2D, tmp_texture); funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); + GL_RGBA, GL_UNSIGNED_BYTE, nullptr); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -326,7 +326,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) funcs->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); funcs->glBindTexture(GL_TEXTURE_2D, oldTexture); - if (pex != 0) + if (pex != nullptr) pex->transferMode(BrushDrawingMode); funcs->glDisable(GL_STENCIL_TEST); @@ -336,9 +336,9 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) funcs->glViewport(0, 0, oldWidth, oldHeight); - QOpenGLShaderProgram *blitProgram = 0; - if (pex == 0) { - if (m_blitProgram == 0) { + QOpenGLShaderProgram *blitProgram = nullptr; + if (pex == nullptr) { + if (m_blitProgram == nullptr) { m_blitProgram = new QOpenGLShaderProgram; const bool isCoreProfile = ctx->format().profile() == QSurfaceFormat::CoreProfile; @@ -408,7 +408,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) funcs->glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)oldFbo); - if (pex != 0) { + if (pex != nullptr) { funcs->glViewport(0, 0, pex->width, pex->height); pex->updateClipScissorTest(); } else { @@ -424,7 +424,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) { QOpenGLContext *ctx = QOpenGLContext::currentContext(); - if (ctx == 0) { + if (ctx == nullptr) { qWarning("QOpenGLTextureGlyphCache::fillTexture: Called with no context"); return; } @@ -447,7 +447,7 @@ int QOpenGLTextureGlyphCache::glyphPadding() const int QOpenGLTextureGlyphCache::maxTextureWidth() const { QOpenGLContext *ctx = const_cast(QOpenGLContext::currentContext()); - if (ctx == 0) + if (ctx == nullptr) return QImageTextureGlyphCache::maxTextureWidth(); else return ctx->d_func()->maxTextureSize(); @@ -456,7 +456,7 @@ int QOpenGLTextureGlyphCache::maxTextureWidth() const int QOpenGLTextureGlyphCache::maxTextureHeight() const { QOpenGLContext *ctx = const_cast(QOpenGLContext::currentContext()); - if (ctx == 0) + if (ctx == nullptr) return QImageTextureGlyphCache::maxTextureHeight(); if (ctx->d_func()->workaround_brokenTexSubImage) @@ -469,10 +469,10 @@ void QOpenGLTextureGlyphCache::clear() { if (m_textureResource) m_textureResource->free(); - m_textureResource = 0; + m_textureResource = nullptr; delete m_blitProgram; - m_blitProgram = 0; + m_blitProgram = nullptr; m_w = 0; m_h = 0; diff --git a/src/gui/opengl/qopengltimerquery.cpp b/src/gui/opengl/qopengltimerquery.cpp index afd2e7887a..a4e10b42f7 100644 --- a/src/gui/opengl/qopengltimerquery.cpp +++ b/src/gui/opengl/qopengltimerquery.cpp @@ -77,8 +77,8 @@ class QOpenGLTimerQueryPrivate : public QObjectPrivate public: QOpenGLTimerQueryPrivate() : QObjectPrivate(), - context(0), - ext(0), + context(nullptr), + ext(nullptr), timeInterval(0), timer(0) { @@ -168,7 +168,7 @@ void QOpenGLTimerQueryPrivate::destroy() core->glDeleteQueries(1, &timer); timer = 0; - context = 0; + context = nullptr; } // GL_TIME_ELAPSED_EXT is not defined on OS X 10.6 @@ -310,14 +310,14 @@ QOpenGLTimerQuery::~QOpenGLTimerQuery() QOpenGLContext* ctx = QOpenGLContext::currentContext(); Q_D(QOpenGLTimerQuery); - QOpenGLContext *oldContext = 0; + QOpenGLContext *oldContext = nullptr; if (d->context != ctx) { oldContext = ctx; if (d->context->makeCurrent(oldContext->surface())) { ctx = d->context; } else { qWarning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to make query objects's context current"); - ctx = 0; + ctx = nullptr; } } @@ -468,9 +468,9 @@ public: : QObjectPrivate(), timers(), timeSamples(), - context(0), - core(0), - ext(0), + context(nullptr), + core(nullptr), + ext(nullptr), requestedSampleCount(2), currentSample(-1), timerQueryActive(false) @@ -556,10 +556,10 @@ void QOpenGLTimeMonitorPrivate::destroy() core->glDeleteQueries(timers.size(), timers.data()); timers.clear(); delete core; - core = 0; + core = nullptr; delete ext; - ext = 0; - context = 0; + ext = nullptr; + context = nullptr; } void QOpenGLTimeMonitorPrivate::recordSample() @@ -701,14 +701,14 @@ QOpenGLTimeMonitor::~QOpenGLTimeMonitor() QOpenGLContext* ctx = QOpenGLContext::currentContext(); Q_D(QOpenGLTimeMonitor); - QOpenGLContext *oldContext = 0; + QOpenGLContext *oldContext = nullptr; if (d->context != ctx) { oldContext = ctx; if (d->context->makeCurrent(oldContext->surface())) { ctx = d->context; } else { qWarning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to make time monitor's context current"); - ctx = 0; + ctx = nullptr; } } diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp index a3d3bb6bd1..5a108335a9 100644 --- a/src/gui/opengl/qopenglversionfunctions.cpp +++ b/src/gui/opengl/qopenglversionfunctions.cpp @@ -68,7 +68,7 @@ void CLASS::init() \ } QOpenGLVersionFunctionsStorage::QOpenGLVersionFunctionsStorage() - : backends(0) + : backends(nullptr) { } diff --git a/src/gui/opengl/qopenglversionfunctionsfactory.cpp b/src/gui/opengl/qopenglversionfunctionsfactory.cpp index fff5eea29c..ca7daedf34 100644 --- a/src/gui/opengl/qopenglversionfunctionsfactory.cpp +++ b/src/gui/opengl/qopenglversionfunctionsfactory.cpp @@ -153,7 +153,7 @@ QAbstractOpenGLFunctions *QOpenGLVersionFunctionsFactory::create(const QOpenGLVe else if (major == 1 && minor == 0) return new QOpenGLFunctions_1_0; } - return 0; + return nullptr; #else Q_UNUSED(versionProfile); return new QOpenGLFunctions_ES2; diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index f0837aff96..f15fe06ee8 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -101,7 +101,7 @@ public: QOpenGLVertexArrayObjectPrivate() : vao(0) , vaoFuncsType(NotSupported) - , context(0) + , context(nullptr) { } @@ -167,7 +167,7 @@ bool QOpenGLVertexArrayObjectPrivate::create() vaoFuncs.helper->glGenVertexArrays(1, &vao); } } else { - vaoFuncs.core_3_0 = 0; + vaoFuncs.core_3_0 = nullptr; vaoFuncsType = NotSupported; QSurfaceFormat format = ctx->format(); #ifndef QT_OPENGL_ES_2 @@ -200,17 +200,17 @@ void QOpenGLVertexArrayObjectPrivate::destroy() Q_Q(QOpenGLVertexArrayObject); QOpenGLContext *ctx = QOpenGLContext::currentContext(); - QOpenGLContext *oldContext = 0; - QSurface *oldContextSurface = 0; + QOpenGLContext *oldContext = nullptr; + QSurface *oldContextSurface = nullptr; QScopedPointer offscreenSurface; if (context && context != ctx) { oldContext = ctx; - oldContextSurface = ctx ? ctx->surface() : 0; + oldContextSurface = ctx ? ctx->surface() : nullptr; // Before going through the effort of creating an offscreen surface // check that we are on the GUI thread because otherwise many platforms // will not able to create that offscreen surface. if (QThread::currentThread() != qGuiApp->thread()) { - ctx = 0; + ctx = nullptr; } else { // Cannot just make the current surface current again with another context. // The format may be incompatible and some platforms (iOS) may impose @@ -223,14 +223,14 @@ void QOpenGLVertexArrayObjectPrivate::destroy() ctx = context; } else { qWarning("QOpenGLVertexArrayObject::destroy() failed to make VAO's context current"); - ctx = 0; + ctx = nullptr; } } } if (context) { QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); - context = 0; + context = nullptr; } if (vao && ctx) { diff --git a/src/gui/painting/qblittable.cpp b/src/gui/painting/qblittable.cpp index 8e2013c24f..494104251f 100644 --- a/src/gui/painting/qblittable.cpp +++ b/src/gui/painting/qblittable.cpp @@ -46,7 +46,7 @@ class QBlittablePrivate { public: QBlittablePrivate(const QSize &size, QBlittable::Capabilities caps) - : caps(caps), m_size(size), locked(false), cachedImg(0) + : caps(caps), m_size(size), locked(false), cachedImg(nullptr) {} QBlittable::Capabilities caps; QSize m_size; diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index abb3268dfa..b23fb45952 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -179,7 +179,7 @@ struct QTexturedBrushData : public QBrushData { QTexturedBrushData() { m_has_pixmap_texture = false; - m_pixmap = 0; + m_pixmap = nullptr; } ~QTexturedBrushData() { delete m_pixmap; @@ -189,7 +189,7 @@ struct QTexturedBrushData : public QBrushData delete m_pixmap; if (pm.isNull()) { - m_pixmap = 0; + m_pixmap = nullptr; m_has_pixmap_texture = false; } else { m_pixmap = new QPixmap(pm); @@ -202,7 +202,7 @@ struct QTexturedBrushData : public QBrushData void setImage(const QImage &image) { m_image = image; delete m_pixmap; - m_pixmap = 0; + m_pixmap = nullptr; m_has_pixmap_texture = false; } @@ -360,7 +360,7 @@ public: { if (!brush->ref.deref()) delete brush; - brush = 0; + brush = nullptr; } }; @@ -831,7 +831,7 @@ const QGradient *QBrush::gradient() const || d->style == Qt::ConicalGradientPattern) { return &static_cast(d.data())->gradient; } - return 0; + return nullptr; } Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush) @@ -968,7 +968,7 @@ bool QBrush::operator==(const QBrush &b) const // but does not share the same data in memory. Since equality is likely to // be used to avoid iterating over the data for a texture update, this should // still be better than doing an accurate comparison. - const QPixmap *us = 0, *them = 0; + const QPixmap *us = nullptr, *them = nullptr; qint64 cacheKey1, cacheKey2; if (qHasPixmapTexture(*this)) { us = (static_cast(d.data()))->m_pixmap; @@ -1335,7 +1335,7 @@ QDataStream &operator>>(QDataStream &s, QBrush &b) \internal */ QGradient::QGradient() - : m_type(NoGradient), dummy(0) + : m_type(NoGradient), dummy(nullptr) { } diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 0fb89a75b5..bece814a6f 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -225,7 +225,7 @@ static StrokeLine strokeLine(int strokeSelection) break; default: Q_ASSERT(false); - stroke = 0; + stroke = nullptr; } return stroke; } @@ -252,8 +252,8 @@ void QCosmeticStroker::setup() const QVector &penPattern = state->lastPen.dashPattern(); if (penPattern.isEmpty()) { Q_ASSERT(!pattern && !reversePattern); - pattern = 0; - reversePattern = 0; + pattern = nullptr; + reversePattern = nullptr; patternLength = 0; patternSize = 0; } else { diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index e8d129d047..6819545bda 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -310,7 +310,7 @@ inline void QT_FASTCALL storePixel(uchar *dest, int index, typedef uint (QT_FASTCALL *FetchPixelFunc)(const uchar *src, int index); static const FetchPixelFunc qFetchPixel[QPixelLayout::BPPCount] = { - 0, // BPPNone + nullptr, // BPPNone fetchPixel, // BPP1MSB fetchPixel, // BPP1LSB fetchPixel, // BPP8 @@ -1713,10 +1713,10 @@ static uint *QT_FASTCALL destFetchUndefined(uint *buffer, QRasterBuffer *, int, static DestFetchProc destFetchProc[QImage::NImageFormats] = { - 0, // Format_Invalid + nullptr, // Format_Invalid destFetchMono, // Format_Mono, destFetchMonoLsb, // Format_MonoLSB - 0, // Format_Indexed8 + nullptr, // Format_Indexed8 destFetchARGB32P, // Format_RGB32 destFetch, // Format_ARGB32, destFetchARGB32P, // Format_ARGB32_Premultiplied @@ -1764,10 +1764,10 @@ static QRgba64 * QT_FASTCALL destFetch64Undefined(QRgba64 *buffer, QRasterBuffer static DestFetchProc64 destFetchProc64[QImage::NImageFormats] = { - 0, // Format_Invalid - 0, // Format_Mono, - 0, // Format_MonoLSB - 0, // Format_Indexed8 + nullptr, // Format_Invalid + nullptr, // Format_Mono, + nullptr, // Format_MonoLSB + nullptr, // Format_Indexed8 destFetch64, // Format_RGB32 destFetch64, // Format_ARGB32, destFetch64, // Format_ARGB32_Premultiplied @@ -1905,13 +1905,13 @@ static void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, int x, int y, con static DestStoreProc destStoreProc[QImage::NImageFormats] = { - 0, // Format_Invalid + nullptr, // Format_Invalid destStoreMono, // Format_Mono, destStoreMonoLsb, // Format_MonoLSB - 0, // Format_Indexed8 - 0, // Format_RGB32 + nullptr, // Format_Indexed8 + nullptr, // Format_RGB32 destStore, // Format_ARGB32, - 0, // Format_ARGB32_Premultiplied + nullptr, // Format_ARGB32_Premultiplied destStoreRGB16, // Format_RGB16 destStore, // Format_ARGB8565_Premultiplied destStore, // Format_RGB666 @@ -1955,10 +1955,10 @@ static void QT_FASTCALL destStore64RGBA64(QRasterBuffer *rasterBuffer, int x, in static DestStoreProc64 destStoreProc64[QImage::NImageFormats] = { - 0, // Format_Invalid - 0, // Format_Mono, - 0, // Format_MonoLSB - 0, // Format_Indexed8 + nullptr, // Format_Invalid + nullptr, // Format_Mono, + nullptr, // Format_MonoLSB + nullptr, // Format_Indexed8 destStore64, // Format_RGB32 destStore64, // Format_ARGB32, destStore64, // Format_ARGB32_Premultiplied @@ -1980,9 +1980,9 @@ static DestStoreProc64 destStoreProc64[QImage::NImageFormats] = destStore64, // Format_A2RGB30_Premultiplied destStore64, // Format_Alpha8 destStore64, // Format_Grayscale8 - 0, // Format_RGBX64 + nullptr, // Format_RGBX64 destStore64RGBA64, // Format_RGBA64 - 0, // Format_RGBA64_Premultiplied + nullptr, // Format_RGBA64_Premultiplied destStore64, // Format_Grayscale16 destStore64, // Format_BGR888 }; @@ -3627,9 +3627,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf #endif fetcher(sbuf1, sbuf2, len, data->texture, fx, fy, fdx, fdy); - layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, 0); + layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, nullptr); if (disty) - layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, nullptr); for (int i = 0; i < len; ++i) { int distx = (fx & 0x0000ffff); @@ -3662,8 +3662,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf fetcher(sbuf1, sbuf2, len, data->texture, fx, fy, fdx, fdy); - layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, nullptr); + layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, nullptr); for (int i = 0; i < len; ++i) { int distx = (fx & 0x0000ffff); @@ -3727,8 +3727,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf fw += fdw; } - layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, nullptr); + layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, nullptr); for (int i = 0; i < len; ++i) { int distx = distxs[i]; @@ -3907,7 +3907,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co // FetchUntransformed can have more specialized methods added depending on SIMD features. static SourceFetchProc sourceFetchUntransformed[QImage::NImageFormats] = { - 0, // Invalid + nullptr, // Invalid fetchUntransformed, // Mono fetchUntransformed, // MonoLsb fetchUntransformed, // Indexed8 @@ -4348,9 +4348,9 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in switch(data->type) { case QSpanData::Solid: solidSource = data->solidColor.isOpaque(); - op.srcFetch = 0; + op.srcFetch = nullptr; #if QT_CONFIG(raster_64bit) - op.srcFetch64 = 0; + op.srcFetch64 = nullptr; #endif break; case QSpanData::LinearGradient: @@ -4721,7 +4721,7 @@ struct QBlendBase QBlendBase(QSpanData *d, const Operator &o) : data(d) , op(o) - , dest(0) + , dest(nullptr) { } @@ -6397,21 +6397,21 @@ static void qt_rectfill_quint64(QRasterBuffer *rasterBuffer, DrawHelper qDrawHelper[QImage::NImageFormats] = { // Format_Invalid, - { 0, 0, 0, 0, 0 }, + { nullptr, nullptr, nullptr, nullptr, nullptr }, // Format_Mono, { blend_color_generic, - 0, 0, 0, 0 + nullptr, nullptr, nullptr, nullptr }, // Format_MonoLSB, { blend_color_generic, - 0, 0, 0, 0 + nullptr, nullptr, nullptr, nullptr }, // Format_Indexed8, { blend_color_generic, - 0, 0, 0, 0 + nullptr, nullptr, nullptr, nullptr }, // Format_RGB32, { @@ -6448,7 +6448,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_ARGB8565_Premultiplied { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6456,7 +6456,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGB666 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6464,7 +6464,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_ARGB6666_Premultiplied { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6472,7 +6472,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGB555 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint16 @@ -6480,7 +6480,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_ARGB8555_Premultiplied { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6488,7 +6488,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGB888 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6496,7 +6496,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGB444 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint16 @@ -6504,7 +6504,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_ARGB4444_Premultiplied { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint16 @@ -6568,7 +6568,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_Alpha8 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_alpha @@ -6576,7 +6576,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_Grayscale8 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_gray @@ -6584,7 +6584,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGBX64 { blend_color_generic_rgb64, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint64 @@ -6592,7 +6592,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGBA64 { blend_color_generic_rgb64, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint64 @@ -6600,7 +6600,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGBA64_Premultiplied { blend_color_generic_rgb64, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint64 @@ -6608,7 +6608,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_Grayscale16 { blend_color_generic_rgb64, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint16 @@ -6616,7 +6616,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_BGR888 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 diff --git a/src/gui/painting/qemulationpaintengine.cpp b/src/gui/painting/qemulationpaintengine.cpp index 0c0df0fb13..7cd700a84a 100644 --- a/src/gui/painting/qemulationpaintengine.cpp +++ b/src/gui/painting/qemulationpaintengine.cpp @@ -271,7 +271,7 @@ void QEmulationPaintEngine::fillBGRect(const QRectF &r) { qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(), r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; - QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint); real_engine->fill(vp, state()->bgBrush); } diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp index 0d7205b483..2e2f65b483 100644 --- a/src/gui/painting/qimagescale.cpp +++ b/src/gui/painting/qimagescale.cpp @@ -223,7 +223,7 @@ static QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi) delete[] isi->yapoints; delete isi; } - return 0; + return nullptr; } static QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img, @@ -238,7 +238,7 @@ static QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img, isi = new QImageScaleInfo; if (!isi) - return 0; + return nullptr; isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1); diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp index 9cb787fb2c..685fbbb37a 100644 --- a/src/gui/painting/qmemrotate.cpp +++ b/src/gui/painting/qmemrotate.cpp @@ -406,9 +406,9 @@ void qt_memrotate270_64(const uchar *srcPixels, int w, int h, int sbpl, uchar *d MemRotateFunc qMemRotateFunctions[QPixelLayout::BPPCount][3] = // 90, 180, 270 { - { 0, 0, 0 }, // BPPNone, - { 0, 0, 0 }, // BPP1MSB, - { 0, 0, 0 }, // BPP1LSB, + { nullptr, nullptr, nullptr }, // BPPNone, + { nullptr, nullptr, nullptr }, // BPP1MSB, + { nullptr, nullptr, nullptr }, // BPP1LSB, { qt_memrotate90_8, qt_memrotate180_8, qt_memrotate270_8 }, // BPP8, { qt_memrotate90_16, qt_memrotate180_16, qt_memrotate270_16 }, // BPP16, { qt_memrotate90_24, qt_memrotate180_24, qt_memrotate270_24 }, // BPP24 diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 2074f98069..67e450986d 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -209,7 +209,7 @@ void QOutlineMapper::endOutline() elements[i] = m_transform.map(elements[i]); } else { const QVectorPath vp((qreal *)elements, m_elements.size(), - m_element_types.size() ? m_element_types.data() : 0); + m_element_types.size() ? m_element_types.data() : nullptr); QPainterPath path = vp.convertToPainterPath(); path = m_transform.map(path); if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL)) diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp index c98ca8a1fb..d73a66b790 100644 --- a/src/gui/painting/qpagesize.cpp +++ b/src/gui/painting/qpagesize.cpp @@ -394,7 +394,7 @@ static QString qt_keyForPageSizeId(QPageSize::PageSizeId id) } // Return id name for PPD Key -static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match = 0) +static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match = nullptr) { if (ppdKey.isEmpty()) return QPageSize::Custom; @@ -415,7 +415,7 @@ static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match } // Return id name for Windows ID -static QPageSize::PageSizeId qt_idForWindowsID(int windowsId, QSize *match = 0) +static QPageSize::PageSizeId qt_idForWindowsID(int windowsId, QSize *match = nullptr) { // If outside known values then is Custom if (windowsId <= DMPAPER_NONE || windowsId > DMPAPER_LAST) @@ -770,7 +770,7 @@ QPageSizePrivate::QPageSizePrivate(const QSize &pointSize, const QString &name, m_units(QPageSize::Point) { if (pointSize.isValid()) { - QPageSize::PageSizeId id = qt_idForPointSize(pointSize, matchPolicy, 0); + QPageSize::PageSizeId id = qt_idForPointSize(pointSize, matchPolicy, nullptr); id == QPageSize::Custom ? init(pointSize, name) : init(id, name); } } @@ -782,7 +782,7 @@ QPageSizePrivate::QPageSizePrivate(const QSizeF &size, QPageSize::Unit units, m_units(QPageSize::Point) { if (size.isValid()) { - QPageSize::PageSizeId id = qt_idForSize(size, units, matchPolicy, 0); + QPageSize::PageSizeId id = qt_idForSize(size, units, matchPolicy, nullptr); id == QPageSize::Custom ? init(size, units, name) : init(id, name); } } @@ -793,10 +793,10 @@ QPageSizePrivate::QPageSizePrivate(const QString &key, const QSize &pointSize, c m_units(QPageSize::Point) { if (!key.isEmpty() && pointSize.isValid()) { - QPageSize::PageSizeId id = qt_idForPpdKey(key, 0); + QPageSize::PageSizeId id = qt_idForPpdKey(key, nullptr); // If not a known PPD key, check if size is a standard PPD size if (id == QPageSize::Custom) - id = qt_idForPointSize(pointSize, QPageSize::FuzzyMatch, 0); + id = qt_idForPointSize(pointSize, QPageSize::FuzzyMatch, nullptr); id == QPageSize::Custom ? init(pointSize, name) : init(id, name); m_key = key; } @@ -808,10 +808,10 @@ QPageSizePrivate::QPageSizePrivate(int windowsId, const QSize &pointSize, const m_units(QPageSize::Point) { if (windowsId > 0 && pointSize.isValid()) { - QPageSize::PageSizeId id = qt_idForWindowsID(windowsId, 0); + QPageSize::PageSizeId id = qt_idForWindowsID(windowsId, nullptr); // If not a known Windows ID, check if size is a standard PPD size if (id == QPageSize::Custom) - id = qt_idForPointSize(pointSize, QPageSize::FuzzyMatch, 0); + id = qt_idForPointSize(pointSize, QPageSize::FuzzyMatch, nullptr); id == QPageSize::Custom ? init(pointSize, name) : init(id, name); m_windowsId = windowsId; } @@ -1753,7 +1753,7 @@ QString QPageSize::name(PageSizeId pageSizeId) QPageSize::PageSizeId QPageSize::id(const QSize &pointSize, SizeMatchPolicy matchPolicy) { - return qt_idForPointSize(pointSize, matchPolicy, 0); + return qt_idForPointSize(pointSize, matchPolicy, nullptr); } /*! @@ -1769,7 +1769,7 @@ QPageSize::PageSizeId QPageSize::id(const QSize &pointSize, SizeMatchPolicy matc QPageSize::PageSizeId QPageSize::id(const QSizeF &size, Unit units, SizeMatchPolicy matchPolicy) { - return qt_idForSize(size, units, matchPolicy, 0); + return qt_idForSize(size, units, matchPolicy, nullptr); } /*! diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 0ddfba6ee9..4afb89b52e 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QPaintDevice::QPaintDevice() noexcept { - reserved = 0; + reserved = nullptr; painters = 0; } @@ -67,7 +67,7 @@ void QPaintDevice::initPainter(QPainter *) const */ QPaintDevice *QPaintDevice::redirected(QPoint *) const { - return 0; + return nullptr; } /*! @@ -75,7 +75,7 @@ QPaintDevice *QPaintDevice::redirected(QPoint *) const */ QPainter *QPaintDevice::sharedPainter() const { - return 0; + return nullptr; } Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric) diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index bfe1c9cadf..1785fcd12d 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -305,7 +305,7 @@ void QPaintEngine::syncState() static_cast(this)->sync(); } -static QPaintEngine *qt_polygon_recursion = 0; +static QPaintEngine *qt_polygon_recursion = nullptr; struct QT_Point { int x; int y; @@ -334,7 +334,7 @@ void QPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDra p[i].y = qRound(points[i].y()); } drawPolygon((QPoint *)p.data(), pointCount, mode); - qt_polygon_recursion = 0; + qt_polygon_recursion = nullptr; } struct QT_PointF { @@ -363,7 +363,7 @@ void QPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDraw p[i].y = points[i].y(); } drawPolygon((QPointF *)p.data(), pointCount, mode); - qt_polygon_recursion = 0; + qt_polygon_recursion = nullptr; } /*! @@ -691,7 +691,7 @@ void QPaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF */ QPaintEngine::QPaintEngine(PaintEngineFeatures caps) - : state(0), + : state(nullptr), gccaps(caps), active(0), selfDestruct(false), @@ -706,7 +706,7 @@ QPaintEngine::QPaintEngine(PaintEngineFeatures caps) */ QPaintEngine::QPaintEngine(QPaintEnginePrivate &dptr, PaintEngineFeatures caps) - : state(0), + : state(nullptr), gccaps(caps), active(0), selfDestruct(false), @@ -728,7 +728,7 @@ QPaintEngine::~QPaintEngine() */ QPainter *QPaintEngine::painter() const { - return state ? state->painter() : 0; + return state ? state->painter() : nullptr; } /*! diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 40c822076b..bc65ed56e3 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -115,17 +115,17 @@ public: pts[7] = bottom; } inline QRectVectorPath(const QRect &r) - : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) + : QVectorPath(pts, 4, nullptr, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) { set(r); } inline QRectVectorPath(const QRectF &r) - : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) + : QVectorPath(pts, 4, nullptr, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) { set(r); } inline QRectVectorPath() - : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) + : QVectorPath(pts, 4, nullptr, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) { } qreal pts[8]; @@ -433,7 +433,7 @@ void QRasterPaintEngine::init() break; default: qWarning("QRasterPaintEngine: unsupported target device %d\n", d->device->devType()); - d->device = 0; + d->device = nullptr; return; } @@ -601,7 +601,7 @@ QRasterPaintEngineState::~QRasterPaintEngineState() QRasterPaintEngineState::QRasterPaintEngineState() { - stroker = 0; + stroker = nullptr; fillFlags = 0; strokeFlags = 0; @@ -621,7 +621,7 @@ QRasterPaintEngineState::QRasterPaintEngineState() flags.tx_noshear = true; flags.fast_images = true; - clip = 0; + clip = nullptr; flags.has_clip_ownership = false; dirty = 0; @@ -643,8 +643,8 @@ QRasterPaintEngineState::QRasterPaintEngineState(QRasterPaintEngineState &s) , dirty(s.dirty) , flag_bits(s.flag_bits) { - brushData.tempImage = 0; - penData.tempImage = 0; + brushData.tempImage = nullptr; + penData.tempImage = nullptr; flags.has_clip_ownership = false; } @@ -759,7 +759,7 @@ void QRasterPaintEngine::updatePen(const QPen &pen) d->dashStroker->setDashOffset(pen.dashOffset()); s->stroker = d->dashStroker.data(); } else { - s->stroker = 0; + s->stroker = nullptr; } ensureRasterState(); // needed because of tx_noshear... @@ -1207,7 +1207,7 @@ static void qrasterpaintengine_state_setNoClip(QRasterPaintEngineState *s) { if (s->flags.has_clip_ownership) delete s->clip; - s->clip = 0; + s->clip = nullptr; s->flags.has_clip_ownership = false; } @@ -1279,14 +1279,14 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) // intersect with, in which case we simplify the operation to // a replace... Qt::ClipOperation isectOp = Qt::IntersectClip; - if (base == 0) + if (base == nullptr) isectOp = Qt::ReplaceClip; QClipData *newClip = new QClipData(d->rasterBuffer->height()); newClip->initialize(); ClipData clipData = { base, newClip, isectOp }; ensureOutlineMapper(); - d->rasterize(d->outlineMapper->convertPath(path), qt_span_clip, &clipData, 0); + d->rasterize(d->outlineMapper->convertPath(path), qt_span_clip, &clipData, nullptr); newClip->fixup(); @@ -1334,7 +1334,7 @@ bool QRasterPaintEngine::setClipRectInDeviceCoords(const QRect &r, Qt::ClipOpera QRect clipRect = qrect_normalized(r) & d->deviceRect; QRasterPaintEngineState *s = state(); - if (op == Qt::ReplaceClip || s->clip == 0) { + if (op == Qt::ReplaceClip || s->clip == nullptr) { // No current clip, hence we intersect with sysclip and be // done with it... @@ -1970,7 +1970,7 @@ void QRasterPaintEngine::fillPolygon(const QPointF *points, int pointCount, Poly } // Compose polygon fill.., - QVectorPath vp((const qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); + QVectorPath vp((const qreal *) points, pointCount, nullptr, QVectorPath::polygonFlags(mode)); ensureOutlineMapper(); QT_FT_Outline *outline = d->outlineMapper->convertPath(vp); @@ -2011,7 +2011,7 @@ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly // Do the outline... if (s->penData.blend) { - QVectorPath vp((const qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); + QVectorPath vp((const qreal *) points, pointCount, nullptr, QVectorPath::polygonFlags(mode)); if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); @@ -2075,7 +2075,7 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg QVarLengthArray fpoints(count); for (int i=0; iflags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); @@ -2695,14 +2695,14 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx } else if (depth == 8) { if (s->penData.alphamapBlit) { s->penData.alphamapBlit(rb, rx, ry, s->penData.solidColor, - scanline, w, h, bpl, 0, useGammaCorrection); + scanline, w, h, bpl, nullptr, useGammaCorrection); return; } } else if (depth == 32) { // (A)RGB Alpha mask where the alpha component is not used. if (s->penData.alphaRGBBlit) { s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solidColor, - (const uint *) scanline, w, h, bpl / 4, 0, useGammaCorrection); + (const uint *) scanline, w, h, bpl / 4, nullptr, useGammaCorrection); return; } } @@ -2917,10 +2917,10 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None ? fontEngine->glyphFormat : d->glyphCacheFormat; QImageTextureGlyphCache *cache = - static_cast(fontEngine->glyphCache(0, glyphFormat, s->matrix, QColor(s->penData.solidColor))); + static_cast(fontEngine->glyphCache(nullptr, glyphFormat, s->matrix, QColor(s->penData.solidColor))); if (!cache) { cache = new QImageTextureGlyphCache(glyphFormat, s->matrix, QColor(s->penData.solidColor)); - fontEngine->setGlyphCache(0, cache); + fontEngine->setGlyphCache(nullptr, cache); } cache->populate(fontEngine, numGlyphs, glyphs, positions); @@ -3672,7 +3672,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, int rasterPoolSize = MINIMUM_POOL_SIZE; uchar rasterPoolOnStack[MINIMUM_POOL_SIZE + 0xf]; uchar *rasterPoolBase = alignAddress(rasterPoolOnStack, 0xf); - uchar *rasterPoolOnHeap = 0; + uchar *rasterPoolOnHeap = nullptr; qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); @@ -3684,13 +3684,13 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, deviceRect.y() + deviceRect.height() }; QT_FT_Raster_Params rasterParams; - rasterParams.target = 0; + rasterParams.target = nullptr; rasterParams.source = outline; rasterParams.flags = QT_FT_RASTER_FLAG_CLIP; - rasterParams.gray_spans = 0; - rasterParams.black_spans = 0; - rasterParams.bit_test = 0; - rasterParams.bit_set = 0; + rasterParams.gray_spans = nullptr; + rasterParams.black_spans = nullptr; + rasterParams.bit_test = nullptr; + rasterParams.bit_set = nullptr; rasterParams.user = data; rasterParams.clip_box = clip_box; @@ -3843,10 +3843,10 @@ QImage::Format QRasterBuffer::prepare(QImage *image) QClipData::QClipData(int height) { clipSpanHeight = height; - m_clipLines = 0; + m_clipLines = nullptr; allocated = 0; - m_spans = 0; + m_spans = nullptr; xmin = xmax = ymin = ymax = 0; count = 0; @@ -3890,7 +3890,7 @@ void QClipData::initialize() const int currMaxY = currMinY + rects[firstInBand].height(); while (y < currMinY) { - m_clipLines[y].spans = 0; + m_clipLines[y].spans = nullptr; m_clipLines[y].count = 0; ++y; } @@ -3922,7 +3922,7 @@ void QClipData::initialize() Q_ASSERT(count <= allocated); while (y < clipSpanHeight) { - m_clipLines[y].spans = 0; + m_clipLines[y].spans = nullptr; m_clipLines[y].count = 0; ++y; } @@ -3936,7 +3936,7 @@ void QClipData::initialize() if (hasRectClip) { int y = 0; while (y < ymin) { - m_clipLines[y].spans = 0; + m_clipLines[y].spans = nullptr; m_clipLines[y].count = 0; ++y; } @@ -3957,19 +3957,19 @@ void QClipData::initialize() } while (y < clipSpanHeight) { - m_clipLines[y].spans = 0; + m_clipLines[y].spans = nullptr; m_clipLines[y].count = 0; ++y; } } } QT_CATCH(...) { free(m_spans); // have to free m_spans again or someone might think that we were successfully initialized. - m_spans = 0; + m_spans = nullptr; QT_RETHROW; } } QT_CATCH(...) { free(m_clipLines); // same for clipLines - m_clipLines = 0; + m_clipLines = nullptr; QT_RETHROW; } } @@ -4044,7 +4044,7 @@ void QClipData::setClipRect(const QRect &rect) if (m_spans) { free(m_spans); - m_spans = 0; + m_spans = nullptr; } // qDebug() << xmin << xmax << ymin << ymax; @@ -4074,7 +4074,7 @@ void QClipData::setClipRegion(const QRegion ®ion) if (m_spans) { free(m_spans); - m_spans = 0; + m_spans = nullptr; } } @@ -4532,7 +4532,7 @@ void QSpanData::init(QRasterBuffer *rb, const QRasterPaintEngine *pe) bilinear = false; m11 = m22 = m33 = 1.; m12 = m13 = m21 = m23 = dx = dy = 0.0; - clip = pe ? pe->d_func()->clip() : 0; + clip = pe ? pe->d_func()->clip() : nullptr; } Q_GUI_EXPORT extern QImage qt_imageForBrush(int brushStyle, bool invert); @@ -4668,15 +4668,15 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode void QSpanData::adjustSpanMethods() { - bitmapBlit = 0; - alphamapBlit = 0; - alphaRGBBlit = 0; + bitmapBlit = nullptr; + alphamapBlit = nullptr; + alphaRGBBlit = nullptr; - fillRect = 0; + fillRect = nullptr; switch(type) { case None: - unclipped_blend = 0; + unclipped_blend = nullptr; break; case Solid: { const DrawHelper &drawHelper = qDrawHelper[rasterBuffer->format]; @@ -4695,17 +4695,17 @@ void QSpanData::adjustSpanMethods() case Texture: unclipped_blend = qBlendTexture; if (!texture.imageData) - unclipped_blend = 0; + unclipped_blend = nullptr; break; } // setup clipping if (!unclipped_blend) { - blend = 0; + blend = nullptr; } else if (!clip) { blend = unclipped_blend; } else if (clip->hasRectClip) { - blend = clip->clipRect.isEmpty() ? 0 : qt_span_fill_clipRect; + blend = clip->clipRect.isEmpty() ? nullptr : qt_span_fill_clipRect; } else { blend = qt_span_fill_clipped; } @@ -4748,7 +4748,7 @@ void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _ { const QImageData *d = const_cast(image)->data_ptr(); if (!d || d->height == 0) { - texture.imageData = 0; + texture.imageData = nullptr; texture.width = 0; texture.height = 0; texture.x1 = 0; @@ -4757,7 +4757,7 @@ void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _ texture.y2 = 0; texture.bytesPerLine = 0; texture.format = QImage::Format_Invalid; - texture.colorTable = 0; + texture.colorTable = nullptr; texture.hasAlpha = alpha != 256; } else { texture.imageData = d->data; @@ -4779,7 +4779,7 @@ void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _ texture.bytesPerLine = d->bytes_per_line; texture.format = d->format; - texture.colorTable = (d->format <= QImage::Format_Indexed8 && !d->colortable.isEmpty()) ? &d->colortable : 0; + texture.colorTable = (d->format <= QImage::Format_Indexed8 && !d->colortable.isEmpty()) ? &d->colortable : nullptr; texture.hasAlpha = image->hasAlphaChannel() || alpha != 256; } texture.const_alpha = alpha; diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 722afaf119..5d8f89eadd 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -115,7 +115,7 @@ QVectorPath::CacheEntry *QVectorPath::addCacheData(QPaintEngineEx *engine, void qvectorpath_cache_cleanup cleanup) const{ Q_ASSERT(!lookupCacheData(engine)); if ((m_hints & IsCachedHint) == 0) { - m_cache = 0; + m_cache = nullptr; m_hints |= IsCachedHint; } CacheEntry *e = new CacheEntry; @@ -162,8 +162,8 @@ struct StrokeHandler { QPaintEngineExPrivate::QPaintEngineExPrivate() : dasher(&stroker), - strokeHandler(0), - activeStroker(0), + strokeHandler(nullptr), + activeStroker(nullptr), strokerPen(Qt::NoPen) { } @@ -211,7 +211,7 @@ void QPaintEngineExPrivate::replayClipOperations() right, info.rectf.y(), right, bottom, info.rectf.x(), bottom }; - QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint); q->clip(vp, info.operation); break; } @@ -418,7 +418,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) if (style == Qt::SolidLine) { d->activeStroker = &d->stroker; } else if (style == Qt::NoPen) { - d->activeStroker = 0; + d->activeStroker = nullptr; } else { d->dasher.setDashPattern(pen.dashPattern()); d->dasher.setDashOffset(pen.dashOffset()); @@ -616,7 +616,7 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op) right, bottom, qreal(r.x()), bottom, qreal(r.x()), qreal(r.y()) }; - QVectorPath vp(pts, 5, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 5, nullptr, QVectorPath::RectangleHint); clip(vp, op); } @@ -687,7 +687,7 @@ void QPaintEngineEx::clip(const QRegion ®ion, Qt::ClipOperation op) void QPaintEngineEx::clip(const QPainterPath &path, Qt::ClipOperation op) { if (path.isEmpty()) { - QVectorPath vp(0, 0); + QVectorPath vp(nullptr, 0); clip(vp, op); } else { clip(qtVectorPathForPath(path), op); @@ -698,7 +698,7 @@ void QPaintEngineEx::fillRect(const QRectF &r, const QBrush &brush) { qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(), r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; - QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint); fill(vp, brush); } @@ -719,7 +719,7 @@ void QPaintEngineEx::drawRects(const QRect *rects, int rectCount) right, bottom, qreal(r.x()), bottom, qreal(r.x()), qreal(r.y()) }; - QVectorPath vp(pts, 5, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 5, nullptr, QVectorPath::RectangleHint); draw(vp); } } @@ -735,7 +735,7 @@ void QPaintEngineEx::drawRects(const QRectF *rects, int rectCount) right, bottom, r.x(), bottom, r.x(), r.y() }; - QVectorPath vp(pts, 5, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 5, nullptr, QVectorPath::RectangleHint); draw(vp); } } @@ -871,7 +871,7 @@ void QPaintEngineEx::drawPoints(const QPointF *points, int pointCount) } else { for (int i=0; ipen); @@ -928,7 +928,7 @@ void QPaintEngineEx::drawPolygon(const QPoint *points, int pointCount, PolygonDr for (int i=0; ipen); @@ -960,7 +960,7 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; - QVectorPath path(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath path(pts, 4, nullptr, QVectorPath::RectangleHint); fill(path, brush); } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index d5cec1b45a..f70bbbd7d2 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -330,7 +330,7 @@ void QPainterPrivate::detachPainterPrivate(QPainter *q) original = new QPainterPrivate(q); } - d_ptrs[refcount - 1] = 0; + d_ptrs[refcount - 1] = nullptr; q->restore(); q->d_ptr.take(); q->d_ptr.reset(original); @@ -338,7 +338,7 @@ void QPainterPrivate::detachPainterPrivate(QPainter *q) if (emulationEngine) { extended = emulationEngine->real_engine; delete emulationEngine; - emulationEngine = 0; + emulationEngine = nullptr; } } @@ -1485,9 +1485,9 @@ QPainter::QPainter() */ QPainter::QPainter(QPaintDevice *pd) - : d_ptr(0) + : d_ptr(nullptr) { - Q_ASSERT(pd != 0); + Q_ASSERT(pd != nullptr); if (!QPainterPrivate::attachPainterPrivate(this, pd)) { d_ptr.reset(new QPainterPrivate(this)); begin(pd); @@ -1718,9 +1718,9 @@ static inline void qt_cleanup_painter_state(QPainterPrivate *d) { qDeleteAll(d->states); d->states.clear(); - d->state = 0; - d->engine = 0; - d->device = 0; + d->state = nullptr; + d->engine = nullptr; + d->device = nullptr; } bool QPainter::begin(QPaintDevice *pd) @@ -1769,13 +1769,13 @@ bool QPainter::begin(QPaintDevice *pd) d->device = pd; - d->extended = d->engine->isExtended() ? static_cast(d->engine) : 0; + d->extended = d->engine->isExtended() ? static_cast(d->engine) : nullptr; if (d->emulationEngine) d->emulationEngine->real_engine = d->extended; // Setup new state... Q_ASSERT(!d->state); - d->state = d->extended ? d->extended->createState(0) : new QPainterState; + d->state = d->extended ? d->extended->createState(nullptr) : new QPainterState; d->state->painter = this; d->states.push_back(d->state); @@ -1915,11 +1915,11 @@ bool QPainter::end() if (d->engine->isActive()) { ended = d->engine->end(); - d->updateState(0); + d->updateState(nullptr); --d->device->painters; if (d->device->painters == 0) { - d->engine->setPaintDevice(0); + d->engine->setPaintDevice(nullptr); d->engine->setActive(false); } } @@ -1935,11 +1935,11 @@ bool QPainter::end() if (d->emulationEngine) { delete d->emulationEngine; - d->emulationEngine = 0; + d->emulationEngine = nullptr; } if (d->extended) { - d->extended = 0; + d->extended = nullptr; } qt_cleanup_painter_state(d); @@ -2761,7 +2761,7 @@ void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op) right, rect.y(), right, bottom, rect.x(), bottom }; - QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint); d->state->clipEnabled = true; d->extended->clip(vp, op); if (op == Qt::ReplaceClip || op == Qt::NoClip) @@ -5642,7 +5642,7 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positio QFixed width = rightMost - leftMost; - if (extended != 0 && state->matrix.isAffine()) { + if (extended != nullptr && state->matrix.isAffine()) { QStaticTextItem staticTextItem; staticTextItem.color = state->pen.color(); staticTextItem.font = state->font; @@ -5685,7 +5685,7 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positio drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()), fontEngine, - 0, // textEngine + nullptr, // textEngine (underline ? QTextCharFormat::SingleUnderline : QTextCharFormat::NoUnderline), @@ -5781,7 +5781,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText // If we don't have an extended paint engine, if the painter is projected, // or if the font engine does not support the matrix, we go through standard // code path - if (d->extended == 0 + if (d->extended == nullptr || !d->state->matrix.isAffine() || !fe->supportsTransformation(d->state->matrix)) { staticText_d->paintText(topLeftPosition, this, pen().color()); @@ -5981,7 +5981,7 @@ void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br d->updateState(d->state); QRectF bounds; - qt_format_text(d->state->font, r, flags, 0, str, br ? &bounds : 0, 0, 0, 0, this); + qt_format_text(d->state->font, r, flags, nullptr, str, br ? &bounds : nullptr, 0, nullptr, 0, this); if (br) *br = bounds.toAlignedRect(); } @@ -6067,7 +6067,7 @@ void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF * if (!d->extended) d->updateState(d->state); - qt_format_text(d->state->font, r, flags, 0, str, br, 0, 0, 0, this); + qt_format_text(d->state->font, r, flags, nullptr, str, br, 0, nullptr, 0, this); } /*! @@ -6185,7 +6185,7 @@ void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption if (!d->extended) d->updateState(d->state); - qt_format_text(d->state->font, r, 0, &o, text, 0, 0, 0, 0, this); + qt_format_text(d->state->font, r, 0, &o, text, nullptr, 0, nullptr, 0, this); } /*! @@ -6415,7 +6415,7 @@ Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t drawTextItemDecoration(painter, QPointF(leftMost.toReal(), baseLine.toReal()), fontEngine, - 0, // textEngine + nullptr, // textEngine font.underline() ? QTextCharFormat::SingleUnderline : QTextCharFormat::NoUnderline, flags, width.toReal(), charFormat); @@ -6425,7 +6425,7 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti) { Q_D(QPainter); - d->drawTextItem(p, ti, static_cast(0)); + d->drawTextItem(p, ti, static_cast(nullptr)); } void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QTextEngine *textEngine) @@ -6682,7 +6682,7 @@ QRectF QPainter::boundingRect(const QRectF &r, const QString &text, const QTextO return QRectF(r.x(),r.y(), 0,0); QRectF br; - qt_format_text(d->state->font, r, Qt::TextDontPrint, &o, text, &br, 0, 0, 0, this); + qt_format_text(d->state->font, r, Qt::TextDontPrint, &o, text, &br, 0, nullptr, 0, this); return br; } @@ -7429,7 +7429,7 @@ void QPainter::setRedirected(const QPaintDevice *device, QPaintDevice *replacement, const QPoint &offset) { - Q_ASSERT(device != 0); + Q_ASSERT(device != nullptr); Q_UNUSED(device) Q_UNUSED(replacement) Q_UNUSED(offset) @@ -7480,7 +7480,7 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) { Q_UNUSED(device) Q_UNUSED(offset) - return 0; + return nullptr; } #endif @@ -7490,7 +7490,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, QPainter *painter) { qt_format_text(fnt, _r, - tf, 0, str, brect, + tf, nullptr, str, brect, tabstops, ta, tabarraylen, painter); } @@ -7500,7 +7500,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, QPainter *painter) { - Q_ASSERT( !((tf & ~Qt::TextDontPrint)!=0 && option!=0) ); // we either have an option or flags + Q_ASSERT( !((tf & ~Qt::TextDontPrint)!=0 && option!=nullptr) ); // we either have an option or flags if (option) { tf |= option->alignment(); diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 859122c3b9..17d8b863ab 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -546,7 +546,7 @@ void QPainterPath::setElementPositionAt(int i, qreal x, qreal y) Constructs an empty QPainterPath object. */ QPainterPath::QPainterPath() noexcept - : d_ptr(0) + : d_ptr(nullptr) { } @@ -602,7 +602,7 @@ void QPainterPath::ensureData_helper() QPainterPath::Element e = { 0, 0, QPainterPath::MoveToElement }; data->elements << e; d_ptr.reset(data); - Q_ASSERT(d_ptr != 0); + Q_ASSERT(d_ptr != nullptr); } /*! @@ -1036,7 +1036,7 @@ void QPainterPath::arcMoveTo(const QRectF &rect, qreal angle) return; QPointF pt; - qt_find_ellipse_coords(rect, angle, 0, &pt, 0); + qt_find_ellipse_coords(rect, angle, 0, &pt, nullptr); moveTo(pt); } diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 924d332452..1a1b2d76e2 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -690,12 +690,12 @@ int QKdPointTree::build(int begin, int end, int depth) if (last > begin) m_nodes.at(last).left = &m_nodes.at(build(begin, last, depth + 1)); else - m_nodes.at(last).left = 0; + m_nodes.at(last).left = nullptr; if (last + 1 < end) m_nodes.at(last).right = &m_nodes.at(build(last + 1, end, depth + 1)); else - m_nodes.at(last).right = 0; + m_nodes.at(last).right = nullptr; return last; } @@ -811,7 +811,7 @@ void QWingedEdge::intersectAndAdd() if (isect->next) { isect += isect->next; } else { - isect = 0; + isect = nullptr; } } @@ -1535,8 +1535,8 @@ QPainterPath QPathClipper::clip(Operation operation) if (subjectPath == clipPath) return op == BoolSub ? QPainterPath() : subjectPath; - bool subjectIsRect = pathToRect(subjectPath, 0); - bool clipIsRect = pathToRect(clipPath, 0); + bool subjectIsRect = pathToRect(subjectPath, nullptr); + bool clipIsRect = pathToRect(clipPath, nullptr); const QRectF clipBounds = clipPath.boundingRect(); const QRectF subjectBounds = subjectPath.boundingRect(); diff --git a/src/gui/painting/qpathsimplifier.cpp b/src/gui/painting/qpathsimplifier.cpp index 4251840bbc..256a2fefe7 100644 --- a/src/gui/painting/qpathsimplifier.cpp +++ b/src/gui/painting/qpathsimplifier.cpp @@ -378,8 +378,8 @@ private: }; inline PathSimplifier::BoundingVolumeHierarchy::BoundingVolumeHierarchy() - : root(0) - , nodeBlock(0) + : root(nullptr) + , nodeBlock(nullptr) , blockSize(0) , firstFree(0) { @@ -392,7 +392,7 @@ inline PathSimplifier::BoundingVolumeHierarchy::~BoundingVolumeHierarchy() inline void PathSimplifier::BoundingVolumeHierarchy::allocate(int nodeCount) { - Q_ASSERT(nodeBlock == 0); + Q_ASSERT(nodeBlock == nullptr); Q_ASSERT(firstFree == 0); nodeBlock = new Node[blockSize = nodeCount]; } @@ -401,9 +401,9 @@ inline void PathSimplifier::BoundingVolumeHierarchy::free() { freeNode(root); delete[] nodeBlock; - nodeBlock = 0; + nodeBlock = nullptr; firstFree = blockSize = 0; - root = 0; + root = nullptr; } inline PathSimplifier::BVHNode *PathSimplifier::BoundingVolumeHierarchy::newNode() @@ -427,7 +427,7 @@ inline void PathSimplifier::BoundingVolumeHierarchy::freeNode(Node *n) } inline PathSimplifier::ElementAllocator::ElementAllocator() - : blocks(0) + : blocks(nullptr) { } @@ -442,11 +442,11 @@ inline PathSimplifier::ElementAllocator::~ElementAllocator() inline void PathSimplifier::ElementAllocator::allocate(int count) { - Q_ASSERT(blocks == 0); + Q_ASSERT(blocks == nullptr); Q_ASSERT(count > 0); blocks = (ElementBlock *)malloc(sizeof(ElementBlock) + (count - 1) * sizeof(Element)); blocks->blockSize = count; - blocks->next = 0; + blocks->next = nullptr; blocks->firstFree = 0; } @@ -479,7 +479,7 @@ inline void PathSimplifier::Element::flip() qSwap(indices[i], indices[degree - i]); } pointingUp = !pointingUp; - Q_ASSERT(next == 0 && previous == 0); + Q_ASSERT(next == nullptr && previous == nullptr); } PathSimplifier::PathSimplifier(const QVectorPath &path, QDataBuffer &vertices, @@ -685,9 +685,9 @@ void PathSimplifier::connectElements() QDataBuffer events(m_elements.size() * 2); for (int i = 0; i < m_elements.size(); ++i) { Element *element = m_elements.at(i); - element->next = element->previous = 0; + element->next = element->previous = nullptr; element->winding = 0; - element->edgeNode = 0; + element->edgeNode = nullptr; const QPoint &u = m_points->at(element->indices[0]); const QPoint &v = m_points->at(element->indices[element->degree]); if (u != v) { @@ -730,7 +730,7 @@ void PathSimplifier::connectElements() Element *element2 = event2->element; element->edgeNode->data = event2->element; element2->edgeNode = element->edgeNode; - element->edgeNode = 0; + element->edgeNode = nullptr; events.pop_back(); events.pop_back(); @@ -783,8 +783,8 @@ void PathSimplifier::connectElements() Element *upperElement = m_elementAllocator.newElement(); *upperElement = *element; upperElement->lowerIndex() = element->upperIndex() = pointIndex; - upperElement->edgeNode = 0; - element->next = element->previous = 0; + upperElement->edgeNode = nullptr; + element->next = element->previous = nullptr; if (upperElement->next) upperElement->next->previous = upperElement; else if (upperElement->previous) @@ -805,7 +805,7 @@ void PathSimplifier::connectElements() RBNode *left = findElementLeftOf(event->element, bounds); RBNode *node = m_elementList.newNode(); node->data = event->element; - Q_ASSERT(event->element->edgeNode == 0); + Q_ASSERT(event->element->edgeNode == nullptr); event->element->edgeNode = node; m_elementList.attachAfter(left, node); } else { @@ -814,7 +814,7 @@ void PathSimplifier::connectElements() Element *element = event->element; Q_ASSERT(element->edgeNode); m_elementList.deleteNode(element->edgeNode); - Q_ASSERT(element->edgeNode == 0); + Q_ASSERT(element->edgeNode == nullptr); } events.pop_back(); } @@ -870,8 +870,8 @@ void PathSimplifier::connectElements() Q_ASSERT(i + 1 < orderedElements.size()); Element *next = orderedElements.at(i); Element *previous = orderedElements.at(i + 1); - Q_ASSERT(next->previous == 0); - Q_ASSERT(previous->next == 0); + Q_ASSERT(next->previous == nullptr); + Q_ASSERT(previous->next == nullptr); next->previous = previous; previous->next = next; } @@ -893,7 +893,7 @@ void PathSimplifier::fillIndices() m_elements.at(i)->processed = false; for (int i = 0; i < m_elements.size(); ++i) { Element *element = m_elements.at(i); - if (element->processed || element->next == 0) + if (element->processed || element->next == nullptr) continue; do { m_indices->add(element->indices[0]); @@ -1395,13 +1395,13 @@ PathSimplifier::RBNode *PathSimplifier::findElementLeftOf(const Element *element const QPair &bounds) { if (!m_elementList.root) - return 0; + return nullptr; RBNode *current = bounds.first; Q_ASSERT(!current || !elementIsLeftOf(element, current->data)); if (!current) current = m_elementList.front(m_elementList.root); Q_ASSERT(current); - RBNode *result = 0; + RBNode *result = nullptr; while (current != bounds.second && !elementIsLeftOf(element, current->data)) { result = current; current = m_elementList.next(current); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index f560e1f0f0..932c3e6f5a 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -439,8 +439,8 @@ QByteArray QPdf::generateDashes(const QPen &pen) static const char* const pattern_for_brush[] = { - 0, // NoBrush - 0, // SolidPattern + nullptr, // NoBrush + nullptr, // SolidPattern "0 J\n" "6 w\n" "[] 0 d\n" @@ -637,7 +637,7 @@ static void cubicToHook(qfixed c1x, qfixed c1y, } QPdf::Stroker::Stroker() - : stream(0), + : stream(nullptr), first(true), dashStroker(&basicStroker) { @@ -652,7 +652,7 @@ QPdf::Stroker::Stroker() void QPdf::Stroker::setPen(const QPen &pen, QPainter::RenderHints hints) { if (pen.style() == Qt::NoPen) { - stroker = 0; + stroker = nullptr; return; } qreal w = pen.widthF(); @@ -1469,7 +1469,7 @@ int QPdfEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const QPdfEnginePrivate::QPdfEnginePrivate() : clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false), pdfVersion(QPdfEngine::Version_1_4), - outDevice(0), ownsDevice(false), + outDevice(nullptr), ownsDevice(false), embedFonts(true), grayscale(false), m_pageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(10, 10, 10, 10)) @@ -1477,8 +1477,8 @@ QPdfEnginePrivate::QPdfEnginePrivate() initResources(); resolution = 1200; currentObject = 1; - currentPage = 0; - stroker.stream = 0; + currentPage = nullptr; + stroker.stream = nullptr; streampos = 0; @@ -1547,12 +1547,12 @@ bool QPdfEngine::end() qDeleteAll(d->fonts); d->fonts.clear(); delete d->currentPage; - d->currentPage = 0; + d->currentPage = nullptr; if (d->outDevice && d->ownsDevice) { d->outDevice->close(); delete d->outDevice; - d->outDevice = 0; + d->outDevice = nullptr; } setActive(false); diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index bf7e2d3dca..35814d146c 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -55,7 +55,7 @@ public: : QObjectPrivate() { engine = new QPdfEngine(); - output = 0; + output = nullptr; pdfVersion = QPdfWriter::PdfVersion_1_4; } ~QPdfWriterPrivate() diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index dc6e3e04d0..1a940443d1 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -254,7 +254,7 @@ public: { if (!pen->ref.deref()) delete pen; - pen = 0; + pen = nullptr; } }; diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 0ecb4390e9..c092a7153f 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -87,10 +87,10 @@ class QPlatformBackingStorePrivate public: QPlatformBackingStorePrivate(QWindow *w) : window(w) - , backingStore(0) + , backingStore(nullptr) #ifndef QT_NO_OPENGL , textureId(0) - , blitter(0) + , blitter(nullptr) #endif { } diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index b4014272f4..cd31d75f83 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -209,7 +209,7 @@ QScanConverter::QScanConverter() : m_lines(0) , m_alloc(0) , m_size(0) - , m_intersections(0) + , m_intersections(nullptr) , m_active(0) { } @@ -442,7 +442,7 @@ void QScanConverter::end() free(m_intersections); m_alloc = 0; m_size = 0; - m_intersections = 0; + m_intersections = nullptr; } if (m_lines.size() > 1024) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 82f5be2b65..783b02fb93 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -1128,7 +1128,7 @@ Q_GUI_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) segments.resize(4 * (end - rect)); int lastRowSegmentCount = 0; - Segment *lastRowSegments = 0; + Segment *lastRowSegments = nullptr; int lastSegment = 0; int lastY = 0; @@ -1380,10 +1380,10 @@ void QRegionPrivate::intersect(const QRect &rect) extents.setRight(qMax(extents.right(), dest->right())); extents.setBottom(qMax(extents.bottom(), dest->bottom())); - const QRect *nextToLast = (numRects > 1 ? dest - 2 : 0); + const QRect *nextToLast = (numRects > 1 ? dest - 2 : nullptr); // mergeFromBelow inlined and optimized - if (canMergeFromBelow(dest - 1, dest, nextToLast, 0)) { + if (canMergeFromBelow(dest - 1, dest, nextToLast, nullptr)) { if (!n || src->y() != dest->y() || src->left() > r.right()) { QRect *prev = dest - 1; prev->setBottom(dest->bottom()); @@ -1408,11 +1408,11 @@ void QRegionPrivate::append(const QRect *r) QRect *myLast = (numRects == 1 ? &extents : rects.data() + (numRects - 1)); if (mergeFromRight(myLast, r)) { if (numRects > 1) { - const QRect *nextToTop = (numRects > 2 ? myLast - 2 : 0); - if (mergeFromBelow(myLast - 1, myLast, nextToTop, 0)) + const QRect *nextToTop = (numRects > 2 ? myLast - 2 : nullptr); + if (mergeFromBelow(myLast - 1, myLast, nextToTop, nullptr)) --numRects; } - } else if (mergeFromBelow(myLast, r, (numRects > 1 ? myLast - 1 : 0), 0)) { + } else if (mergeFromBelow(myLast, r, (numRects > 1 ? myLast - 1 : nullptr), nullptr)) { // nothing } else { vectorize(); @@ -1451,18 +1451,18 @@ void QRegionPrivate::append(const QRegionPrivate *r) { const QRect *rFirst = srcRect; QRect *myLast = destRect - 1; - const QRect *nextToLast = (numRects > 1 ? myLast - 1 : 0); + const QRect *nextToLast = (numRects > 1 ? myLast - 1 : nullptr); if (mergeFromRight(myLast, rFirst)) { ++srcRect; --numAppend; - const QRect *rNextToFirst = (numAppend > 1 ? rFirst + 2 : 0); + const QRect *rNextToFirst = (numAppend > 1 ? rFirst + 2 : nullptr); if (mergeFromBelow(myLast, rFirst + 1, nextToLast, rNextToFirst)) { ++srcRect; --numAppend; } if (numRects > 1) { - nextToLast = (numRects > 2 ? myLast - 2 : 0); - rNextToFirst = (numAppend > 0 ? srcRect : 0); + nextToLast = (numRects > 2 ? myLast - 2 : nullptr); + rNextToFirst = (numAppend > 0 ? srcRect : nullptr); if (mergeFromBelow(myLast - 1, myLast, nextToLast, rNextToFirst)) { --destRect; --numRects; @@ -1522,20 +1522,20 @@ void QRegionPrivate::prepend(const QRegionPrivate *r) // try merging { QRect *myFirst = rects.data(); - const QRect *nextToFirst = (numRects > 1 ? myFirst + 1 : 0); + const QRect *nextToFirst = (numRects > 1 ? myFirst + 1 : nullptr); const QRect *rLast = r->rects.constData() + r->numRects - 1; - const QRect *rNextToLast = (r->numRects > 1 ? rLast - 1 : 0); + const QRect *rNextToLast = (r->numRects > 1 ? rLast - 1 : nullptr); if (mergeFromLeft(myFirst, rLast)) { --numPrepend; --rLast; - rNextToLast = (numPrepend > 1 ? rLast - 1 : 0); + rNextToLast = (numPrepend > 1 ? rLast - 1 : nullptr); if (mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast)) { --numPrepend; --rLast; } if (numRects > 1) { - nextToFirst = (numRects > 2? myFirst + 2 : 0); - rNextToLast = (numPrepend > 0 ? rLast : 0); + nextToFirst = (numRects > 2? myFirst + 2 : nullptr); + rNextToLast = (numPrepend > 0 ? rLast : nullptr); if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, rNextToLast)) { --numRects; ++numSkip; @@ -1585,14 +1585,14 @@ void QRegionPrivate::prepend(const QRect *r) QRect *myFirst = (numRects == 1 ? &extents : rects.data()); if (mergeFromLeft(myFirst, r)) { if (numRects > 1) { - const QRect *nextToFirst = (numRects > 2 ? myFirst + 2 : 0); - if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, 0)) { + const QRect *nextToFirst = (numRects > 2 ? myFirst + 2 : nullptr); + if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, nullptr)) { --numRects; memmove(rects.data(), rects.constData() + 1, numRects * sizeof(QRect)); } } - } else if (mergeFromAbove(myFirst, r, (numRects > 1 ? myFirst + 1 : 0), 0)) { + } else if (mergeFromAbove(myFirst, r, (numRects > 1 ? myFirst + 1 : nullptr), nullptr)) { // nothing } else { vectorize(); @@ -2324,14 +2324,14 @@ static void miRegionOp(QRegionPrivate &dest, top = qMax(r1->top(), ybot + 1); bot = qMin(r1->bottom(), r2->top() - 1); - if (nonOverlap1Func != 0 && bot >= top) + if (nonOverlap1Func != nullptr && bot >= top) (*nonOverlap1Func)(dest, r1, r1BandEnd, top, bot); ytop = r2->top(); } else if (r2->top() < r1->top()) { top = qMax(r2->top(), ybot + 1); bot = qMin(r2->bottom(), r1->top() - 1); - if (nonOverlap2Func != 0 && bot >= top) + if (nonOverlap2Func != nullptr && bot >= top) (*nonOverlap2Func)(dest, r2, r2BandEnd, top, bot); ytop = r1->top(); } else { @@ -2374,7 +2374,7 @@ static void miRegionOp(QRegionPrivate &dest, */ curBand = dest.numRects; if (r1 != r1End) { - if (nonOverlap1Func != 0) { + if (nonOverlap1Func != nullptr) { do { r1BandEnd = r1; while (r1BandEnd < r1End && r1BandEnd->top() == r1->top()) @@ -2383,7 +2383,7 @@ static void miRegionOp(QRegionPrivate &dest, r1 = r1BandEnd; } while (r1 != r1End); } - } else if ((r2 != r2End) && (nonOverlap2Func != 0)) { + } else if ((r2 != r2End) && (nonOverlap2Func != nullptr)) { do { r2BandEnd = r2; while (r2BandEnd < r2End && r2BandEnd->top() == r2->top()) @@ -2698,7 +2698,7 @@ static void SubtractRegion(QRegionPrivate *regM, QRegionPrivate *regS, Q_ASSERT(!regS->contains(*regM)); Q_ASSERT(!EqualRegion(regM, regS)); - miRegionOp(dest, regM, regS, miSubtractO, miSubtractNonO1, 0); + miRegionOp(dest, regM, regS, miSubtractO, miSubtractNonO1, nullptr); /* * Can't alter dest's extents before we call miRegionOp because @@ -3235,14 +3235,14 @@ static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline, (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); Q_CHECK_PTR(tmpSLLBlock); (*SLLBlock)->next = tmpSLLBlock; - tmpSLLBlock->next = (ScanLineListBlock *)NULL; + tmpSLLBlock->next = (ScanLineListBlock *)nullptr; *SLLBlock = tmpSLLBlock; *iSLLBlock = 0; } pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]); pSLL->next = pPrevSLL->next; - pSLL->edgelist = (EdgeTableEntry *)NULL; + pSLL->edgelist = (EdgeTableEntry *)nullptr; pPrevSLL->next = pSLL; } pSLL->scanline = scanline; @@ -3250,7 +3250,7 @@ static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline, /* * now insert the edge in the right bucket */ - prev = 0; + prev = nullptr; start = pSLL->edgelist; while (start && (start->bres.minor_axis < ETE->bres.minor_axis)) { prev = start; @@ -3306,18 +3306,18 @@ static void CreateETandAET(int count, const QPoint *pts, /* * initialize the Active Edge Table */ - AET->next = 0; - AET->back = 0; - AET->nextWETE = 0; + AET->next = nullptr; + AET->back = nullptr; + AET->nextWETE = nullptr; AET->bres.minor_axis = SMALL_COORDINATE; /* * initialize the Edge Table. */ - ET->scanlines.next = 0; + ET->scanlines.next = nullptr; ET->ymax = SMALL_COORDINATE; ET->ymin = LARGE_COORDINATE; - pSLLBlock->next = 0; + pSLLBlock->next = nullptr; PrevPt = &pts[count - 1]; @@ -3426,7 +3426,7 @@ static void computeWAET(EdgeTableEntry *AET) int inside = 1; int isInside = 0; - AET->nextWETE = 0; + AET->nextWETE = nullptr; pWETE = AET; AET = AET->next; while (AET) { @@ -3442,7 +3442,7 @@ static void computeWAET(EdgeTableEntry *AET) } AET = AET->next; } - pWETE->nextWETE = 0; + pWETE->nextWETE = nullptr; } /* @@ -3672,7 +3672,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) if (!(pETEs = static_cast(malloc(sizeof(EdgeTableEntry) * Count)))) { delete region; - return 0; + return nullptr; } region->vectorize(); @@ -3692,7 +3692,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) #endif delete AET; delete region; - return 0; + return nullptr; } @@ -3808,7 +3808,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) curPtBlock = tmpPtBlock; } free(pETEs); - return 0; // this function returns 0 in case of an error + return nullptr; // this function returns 0 in case of an error } FreeStorage(SLLBlock.next); @@ -4185,7 +4185,7 @@ QRegion QRegion::intersected(const QRegion &r) const QRegion result; result.detach(); - miRegionOp(*result.d->qt_rgn, d->qt_rgn, r.d->qt_rgn, miIntersectO, 0, 0); + miRegionOp(*result.d->qt_rgn, d->qt_rgn, r.d->qt_rgn, miIntersectO, nullptr, nullptr); /* * Can't alter dest's extents before we call miRegionOp because diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 271d3ba6bf..22302f9790 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -185,10 +185,10 @@ QStrokerOps::QStrokerOps() : m_elements(0) , m_curveThreshold(qt_real_to_fixed(0.25)) , m_dashThreshold(qt_real_to_fixed(0.25)) - , m_customData(0) - , m_moveTo(0) - , m_lineTo(0) - , m_cubicTo(0) + , m_customData(nullptr) + , m_moveTo(nullptr) + , m_lineTo(nullptr) + , m_cubicTo(nullptr) { } @@ -219,7 +219,7 @@ void QStrokerOps::end() { if (m_elements.size() > 1) processCurrentSubpath(); - m_customData = 0; + m_customData = nullptr; } /*! diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 7a3dd04965..f40ca9d8b4 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -127,7 +127,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const QFixed subPixelPosition; if (supportsSubPixelPositions) { - QFixed x = positions != 0 ? positions[i].x : QFixed(); + QFixed x = positions != nullptr ? positions[i].x : QFixed(); subPixelPosition = fontEngine->subPixelPositionForX(x); } diff --git a/src/gui/painting/qtriangulatingstroker.cpp b/src/gui/painting/qtriangulatingstroker.cpp index b1b07f9699..8e0308f268 100644 --- a/src/gui/painting/qtriangulatingstroker.cpp +++ b/src/gui/painting/qtriangulatingstroker.cpp @@ -150,7 +150,7 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, co m_cos_theta = qFastCos(Q_PI / m_roundness); const qreal *endPts = pts + (count<<1); - const qreal *startPts = 0; + const qreal *startPts = nullptr; Qt::PenCapStyle cap = m_cap_style; @@ -510,7 +510,7 @@ static void qdashprocessor_cubicTo(qreal, qreal, qreal, qreal, qreal, qreal, voi QDashedStrokeProcessor::QDashedStrokeProcessor() : m_points(0), m_types(0), - m_dash_stroker(0), m_inv_scale(1) + m_dash_stroker(nullptr), m_inv_scale(1) { m_dash_stroker.setMoveToHook(qdashprocessor_moveTo); m_dash_stroker.setLineToHook(qdashprocessor_lineTo); diff --git a/src/gui/painting/qtriangulator.cpp b/src/gui/painting/qtriangulator.cpp index 9be3eeaffd..ec3ab8ff8f 100644 --- a/src/gui/painting/qtriangulator.cpp +++ b/src/gui/painting/qtriangulator.cpp @@ -958,7 +958,7 @@ void QTriangulator::ComplexToSimple::initEdges() } else { Q_ASSERT(i + 1 < m_parent->m_indices.size()); // {node, from, to, next, previous, winding, mayIntersect, pointingUp, originallyPointingUp} - Edge edge = {0, int(m_parent->m_indices.at(i)), int(m_parent->m_indices.at(i + 1)), -1, -1, 0, true, false, false}; + Edge edge = {nullptr, int(m_parent->m_indices.at(i)), int(m_parent->m_indices.at(i + 1)), -1, -1, 0, true, false, false}; m_edges.add(edge); } } @@ -1029,7 +1029,7 @@ template QRBTree::Node *QTriangulator::ComplexToSimple::searchEdgeLeftOf(int edgeIndex) const { QRBTree::Node *current = m_edgeList.root; - QRBTree::Node *result = 0; + QRBTree::Node *result = nullptr; while (current) { if (edgeIsLeftOfEdge(edgeIndex, current->data)) { current = current->left; @@ -1072,7 +1072,7 @@ QPair::Node *, QRBTree::Node *> QTriangulator::ComplexToSim } current = (d < 0 ? current->left : current->right); } - if (current == 0) + if (current == nullptr) return result; current = result.first->left; @@ -1273,7 +1273,7 @@ void QTriangulator::ComplexToSimple::fillPriorityQueue() m_events.reserve(m_edges.size() * 2); for (int i = 0; i < m_edges.size(); ++i) { Q_ASSERT(m_edges.at(i).previous == -1 && m_edges.at(i).next == -1); - Q_ASSERT(m_edges.at(i).node == 0); + Q_ASSERT(m_edges.at(i).node == nullptr); Q_ASSERT(m_edges.at(i).pointingUp == m_edges.at(i).originallyPointingUp); Q_ASSERT(m_edges.at(i).pointingUp == (m_parent->m_vertices.at(m_edges.at(i).to) < m_parent->m_vertices.at(m_edges.at(i).from))); // Ignore zero-length edges. @@ -1296,7 +1296,7 @@ void QTriangulator::ComplexToSimple::calculateIntersections() fillPriorityQueue(); Q_ASSERT(m_topIntersection.empty()); - Q_ASSERT(m_edgeList.root == 0); + Q_ASSERT(m_edgeList.root == nullptr); // Find all intersection points. while (!m_events.isEmpty()) { @@ -1305,7 +1305,7 @@ void QTriangulator::ComplexToSimple::calculateIntersections() // Find all edges in the edge list that contain the current vertex and mark them to be split later. QPair::Node *, QRBTree::Node *> range = bounds(event.point); - QRBTree::Node *leftNode = range.first ? m_edgeList.previous(range.first) : 0; + QRBTree::Node *leftNode = range.first ? m_edgeList.previous(range.first) : nullptr; int vertex = (event.type == Event::Upper ? m_edges.at(event.edge).upper() : m_edges.at(event.edge).lower()); QIntersectionPoint eventPoint = QT_PREPEND_NAMESPACE(qIntersectionPoint)(event.point); @@ -1361,7 +1361,7 @@ int QTriangulator::ComplexToSimple::splitEdge(int splitIndex) { const Split &split = m_splits.at(splitIndex); Edge &lowerEdge = m_edges.at(split.edge); - Q_ASSERT(lowerEdge.node == 0); + Q_ASSERT(lowerEdge.node == nullptr); Q_ASSERT(lowerEdge.previous == -1 && lowerEdge.next == -1); if (lowerEdge.from == split.vertex) @@ -1439,7 +1439,7 @@ void QTriangulator::ComplexToSimple::insertEdgeIntoVectorIfWanted(ShortArray template void QTriangulator::ComplexToSimple::removeUnwantedEdgesAndConnect() { - Q_ASSERT(m_edgeList.root == 0); + Q_ASSERT(m_edgeList.root == nullptr); // Initialize priority queue. fillPriorityQueue(); @@ -1772,7 +1772,7 @@ void QTriangulator::SimpleToMonotone::setupDataStructures() { int i = 0; Edge e; - e.node = 0; + e.node = nullptr; e.twin = -1; while (i + 3 <= m_parent->m_indices.size()) { @@ -1862,7 +1862,7 @@ template QRBTree::Node *QTriangulator::SimpleToMonotone::searchEdgeLeftOfEdge(int edgeIndex) const { QRBTree::Node *current = m_edgeList.root; - QRBTree::Node *result = 0; + QRBTree::Node *result = nullptr; while (current) { if (edgeIsLeftOfEdge(edgeIndex, current->data)) { current = current->left; @@ -1879,7 +1879,7 @@ template QRBTree::Node *QTriangulator::SimpleToMonotone::searchEdgeLeftOfPoint(int pointIndex) const { QRBTree::Node *current = m_edgeList.root; - QRBTree::Node *result = 0; + QRBTree::Node *result = nullptr; while (current) { const QPodPoint &p1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); const QPodPoint &p2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); @@ -2038,7 +2038,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() j = m_edges.at(i).previous; Q_ASSERT(j < m_edges.size()); - QRBTree::Node *leftEdgeNode = 0; + QRBTree::Node *leftEdgeNode = nullptr; switch (m_edges.at(i).type) { case RegularVertex: @@ -2049,7 +2049,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() if (m_edges.at(m_edges.at(i).helper).type == MergeVertex) diagonals.add(QPair(i, m_edges.at(i).helper)); m_edges.at(j).node = m_edges.at(i).node; - m_edges.at(i).node = 0; + m_edges.at(i).node = nullptr; m_edges.at(j).node->data = j; m_edges.at(j).helper = i; } else if (m_edges.at(j).node) { @@ -2057,7 +2057,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() if (m_edges.at(m_edges.at(j).helper).type == MergeVertex) diagonals.add(QPair(i, m_edges.at(j).helper)); m_edges.at(i).node = m_edges.at(j).node; - m_edges.at(j).node = 0; + m_edges.at(j).node = nullptr; m_edges.at(i).node->data = i; m_edges.at(i).helper = i; } else { diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index 8b8f3e28ac..8528f59844 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -471,7 +471,7 @@ QTextObjectInterface *QAbstractTextDocumentLayout::handlerForObject(int objectTy QTextObjectHandler handler = d->handlers.value(objectType); if (!handler.component) - return 0; + return nullptr; return handler.iface; } diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 89f943ca51..c843e3b706 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -850,7 +850,7 @@ QDistanceFieldData::QDistanceFieldData(const QDistanceFieldData &other) if (nbytes && other.data) data = (uchar *)memcpy(malloc(nbytes), other.data, nbytes); else - data = 0; + data = nullptr; } QDistanceFieldData::~QDistanceFieldData() @@ -1046,7 +1046,7 @@ const uchar *QDistanceField::constBits() const uchar *QDistanceField::scanLine(int i) { if (isNull()) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < d->height); return d->data + i * d->width; @@ -1055,7 +1055,7 @@ uchar *QDistanceField::scanLine(int i) const uchar *QDistanceField::scanLine(int i) const { if (isNull()) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < d->height); return d->data + i * d->width; @@ -1064,7 +1064,7 @@ const uchar *QDistanceField::scanLine(int i) const const uchar *QDistanceField::constScanLine(int i) const { if (isNull()) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < d->height); return d->data + i * d->width; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index bf130fa0b7..e162015aba 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -180,14 +180,14 @@ Q_GUI_EXPORT int qt_defaultDpi() } QFontPrivate::QFontPrivate() - : engineData(0), dpi(qt_defaultDpi()), + : engineData(nullptr), dpi(qt_defaultDpi()), underline(false), overline(false), strikeOut(false), kerning(true), - capital(0), letterSpacingIsAbsolute(false), scFont(0) + capital(0), letterSpacingIsAbsolute(false), scFont(nullptr) { } QFontPrivate::QFontPrivate(const QFontPrivate &other) - : request(other.request), engineData(0), dpi(other.dpi), + : request(other.request), engineData(nullptr), dpi(other.dpi), underline(other.underline), overline(other.overline), strikeOut(other.strikeOut), kerning(other.kerning), capital(other.capital), letterSpacingIsAbsolute(other.letterSpacingIsAbsolute), @@ -202,10 +202,10 @@ QFontPrivate::~QFontPrivate() { if (engineData && !engineData->ref.deref()) delete engineData; - engineData = 0; + engineData = nullptr; if (scFont && scFont != this) scFont->ref.deref(); - scFont = 0; + scFont = nullptr; } extern QRecursiveMutex *qt_fontdatabase_mutex(); @@ -221,7 +221,7 @@ QFontEngine *QFontPrivate::engineForScript(int script) const // throw out engineData that came from a different thread if (!engineData->ref.deref()) delete engineData; - engineData = 0; + engineData = nullptr; } if (!engineData || !QT_FONT_ENGINE_FROM_DATA(engineData, script)) QFontDatabase::load(this, script); @@ -261,7 +261,7 @@ QFontPrivate *QFontPrivate::smallCapsFontPrivate() const void QFontPrivate::resolve(uint mask, const QFontPrivate *other) { - Q_ASSERT(other != 0); + Q_ASSERT(other != nullptr); dpi = other->dpi; @@ -346,7 +346,7 @@ QFontEngineData::~QFontEngineData() if (engines[i]) { if (!engines[i]->ref.deref()) delete engines[i]; - engines[i] = 0; + engines[i] = nullptr; } } } @@ -610,10 +610,10 @@ void QFont::detach() if (d->ref.loadRelaxed() == 1) { if (d->engineData && !d->engineData->ref.deref()) delete d->engineData; - d->engineData = 0; + d->engineData = nullptr; if (d->scFont && d->scFont != d.data()) d->scFont->ref.deref(); - d->scFont = 0; + d->scFont = nullptr; return; } @@ -1666,7 +1666,7 @@ void QFont::setRawMode(bool) bool QFont::exactMatch() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return d->request.exactMatch(engine->fontDef); } @@ -1834,7 +1834,7 @@ Q_GLOBAL_STATIC(QFontSubst, globalFontSubst) QString QFont::substitute(const QString &familyName) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); QFontSubst::ConstIterator it = fontSubst->constFind(familyName.toLower()); if (it != fontSubst->constEnd() && !(*it).isEmpty()) return (*it).first(); @@ -1855,7 +1855,7 @@ QString QFont::substitute(const QString &familyName) QStringList QFont::substitutes(const QString &familyName) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); return fontSubst->value(familyName.toLower(), QStringList()); } @@ -1870,7 +1870,7 @@ void QFont::insertSubstitution(const QString &familyName, const QString &substituteName) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); QStringList &list = (*fontSubst)[familyName.toLower()]; QString s = substituteName.toLower(); if (!list.contains(s)) @@ -1888,7 +1888,7 @@ void QFont::insertSubstitutions(const QString &familyName, const QStringList &substituteNames) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); QStringList &list = (*fontSubst)[familyName.toLower()]; for (const QString &substituteName : substituteNames) { const QString lowerSubstituteName = substituteName.toLower(); @@ -1906,7 +1906,7 @@ void QFont::insertSubstitutions(const QString &familyName, void QFont::removeSubstitutions(const QString &familyName) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); fontSubst->remove(familyName.toLower()); } @@ -1926,7 +1926,7 @@ void QFont::removeSubstitutions(const QString &familyName) QStringList QFont::substitutions() { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); QStringList ret = fontSubst->keys(); ret.sort(); @@ -1940,7 +1940,7 @@ QStringList QFont::substitutions() */ static quint8 get_font_bits(int version, const QFontPrivate *f) { - Q_ASSERT(f != 0); + Q_ASSERT(f != nullptr); quint8 bits = 0; if (f->request.style) bits |= 0x01; @@ -1965,7 +1965,7 @@ static quint8 get_font_bits(int version, const QFontPrivate *f) static quint8 get_extended_font_bits(const QFontPrivate *f) { - Q_ASSERT(f != 0); + Q_ASSERT(f != nullptr); quint8 bits = 0; if (f->request.ignorePitch) bits |= 0x01; @@ -1980,7 +1980,7 @@ static quint8 get_extended_font_bits(const QFontPrivate *f) */ static void set_font_bits(int version, quint8 bits, QFontPrivate *f) { - Q_ASSERT(f != 0); + Q_ASSERT(f != nullptr); f->request.style = (bits & 0x01) != 0 ? QFont::StyleItalic : QFont::StyleNormal; f->underline = (bits & 0x02) != 0; f->overline = (bits & 0x40) != 0; @@ -1995,7 +1995,7 @@ static void set_font_bits(int version, quint8 bits, QFontPrivate *f) static void set_extended_font_bits(quint8 bits, QFontPrivate *f) { - Q_ASSERT(f != 0); + Q_ASSERT(f != nullptr); f->request.ignorePitch = (bits & 0x01) != 0; f->letterSpacingIsAbsolute = (bits & 0x02) != 0; } @@ -2549,7 +2549,7 @@ QFontInfo &QFontInfo::operator=(const QFontInfo &fi) QString QFontInfo::family() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.family; } @@ -2564,7 +2564,7 @@ QString QFontInfo::family() const QString QFontInfo::styleName() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.styleName; } @@ -2576,7 +2576,7 @@ QString QFontInfo::styleName() const int QFontInfo::pointSize() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->fontDef.pointSize); } @@ -2588,7 +2588,7 @@ int QFontInfo::pointSize() const qreal QFontInfo::pointSizeF() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.pointSize; } @@ -2600,7 +2600,7 @@ qreal QFontInfo::pointSizeF() const int QFontInfo::pixelSize() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.pixelSize; } @@ -2612,7 +2612,7 @@ int QFontInfo::pixelSize() const bool QFontInfo::italic() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.style != QFont::StyleNormal; } @@ -2624,7 +2624,7 @@ bool QFontInfo::italic() const QFont::Style QFontInfo::style() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return (QFont::Style)engine->fontDef.style; } @@ -2636,7 +2636,7 @@ QFont::Style QFontInfo::style() const int QFontInfo::weight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.weight; } @@ -2701,7 +2701,7 @@ bool QFontInfo::strikeOut() const bool QFontInfo::fixedPitch() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); #ifdef Q_OS_MAC if (!engine->fontDef.fixedPitchComputed) { QChar ch[2] = { QLatin1Char('i'), QLatin1Char('m') }; @@ -2727,7 +2727,7 @@ bool QFontInfo::fixedPitch() const QFont::StyleHint QFontInfo::styleHint() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return (QFont::StyleHint) engine->fontDef.styleHint; } @@ -2759,7 +2759,7 @@ bool QFontInfo::rawMode() const bool QFontInfo::exactMatch() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return d->request.exactMatch(engine->fontDef); } @@ -2793,7 +2793,7 @@ QFontCache *QFontCache::instance() void QFontCache::cleanup() { - QThreadStorage *cache = 0; + QThreadStorage *cache = nullptr; QT_TRY { cache = theFontCache(); } QT_CATCH (const std::bad_alloc &) { @@ -2830,7 +2830,7 @@ void QFontCache::clear() Q_ASSERT(engineCacheCount.value(data->engines[i]) == 0); delete data->engines[i]; } - data->engines[i] = 0; + data->engines[i] = nullptr; } } if (!data->ref.deref()) { @@ -2863,7 +2863,7 @@ void QFontCache::clear() FC_DEBUG("QFontCache::clear: engine %p still has refcount %d", engine, engine->ref.loadRelaxed()); } - it.value().data = 0; + it.value().data = nullptr; } } } while (mightHaveEnginesLeftForCleanup); @@ -2881,7 +2881,7 @@ QFontEngineData *QFontCache::findEngineData(const QFontDef &def) const { EngineDataCache::ConstIterator it = engineDataCache.constFind(def); if (it == engineDataCache.constEnd()) - return 0; + return nullptr; // found return it.value(); @@ -2912,7 +2912,7 @@ QFontEngine *QFontCache::findEngine(const Key &key) { EngineCache::Iterator it = engineCache.find(key), end = engineCache.end(); - if (it == end) return 0; + if (it == end) return nullptr; Q_ASSERT(it.value().data != nullptr); Q_ASSERT(key.multi == (it.value().data->type() == QFontEngine::Multi)); diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 67702ab5b5..f2fd585835 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -210,7 +210,7 @@ struct QtFontStyle QtFontStyle(const Key &k) : key(k), bitmapScalable(false), smoothScalable(false), - count(0), pixelSizes(0) + count(0), pixelSizes(nullptr) { } @@ -265,7 +265,7 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add) return pixelSizes + i; } if (!add) - return 0; + return nullptr; if (!pixelSizes) { // Most style have only one font size, we avoid waisting memory @@ -280,13 +280,13 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add) pixelSizes = newPixelSizes; } pixelSizes[count].pixelSize = size; - pixelSizes[count].handle = 0; + pixelSizes[count].handle = nullptr; return pixelSizes + (count++); } struct QtFontFoundry { - QtFontFoundry(const QString &n) : name(n), count(0), styles(0) {} + QtFontFoundry(const QString &n) : name(n), count(0), styles(nullptr) {} ~QtFontFoundry() { while (count--) delete styles[count]; @@ -314,7 +314,7 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &st } } if (!create) - return 0; + return nullptr; // qDebug("adding key (weight=%d, style=%d, oblique=%d stretch=%d) at %d", key.weight, key.style, key.oblique, key.stretch, pos); if (!(count % 8)) { @@ -345,7 +345,7 @@ struct QtFontFamily : populated(false), fixedPitch(false), - name(n), count(0), foundries(0) + name(n), count(0), foundries(nullptr) { memset(writingSystems, 0, sizeof(writingSystems)); } @@ -381,7 +381,7 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) return foundries[i]; } if (!create) - return 0; + return nullptr; if (!(count % 8)) { QtFontFoundry **newFoundries = (QtFontFoundry **) @@ -450,7 +450,7 @@ class QFontDatabasePrivate { public: QFontDatabasePrivate() - : count(0), families(0), + : count(0), families(nullptr), fallbacksCache(64) { } @@ -469,7 +469,7 @@ public: while (count--) delete families[count]; ::free(families); - families = 0; + families = nullptr; count = 0; // don't clear the memory fonts! } @@ -505,7 +505,7 @@ void QFontDatabasePrivate::invalidate() QtFontFamily *QFontDatabasePrivate::family(const QString &f, FamilyRequestFlags flags) { - QtFontFamily *fam = 0; + QtFontFamily *fam = nullptr; int low = 0; int high = count; @@ -645,7 +645,7 @@ static void parseFontName(const QString &name, QString &foundry, QString &family struct QtFontDesc { - inline QtFontDesc() : family(0), foundry(0), style(0), size(0) {} + inline QtFontDesc() : family(nullptr), foundry(nullptr), style(nullptr), size(nullptr) {} QtFontFamily *family; QtFontFoundry *foundry; QtFontStyle *style; @@ -949,7 +949,7 @@ QFontEngine *loadSingleEngine(int script, if (Q_UNLIKELY(!engine->supportsScript(QChar::Script(script)))) { qWarning(" OpenType support missing for \"%s\", script %d", qPrintable(def.family), script); - return 0; + return nullptr; } engine->isSmoothlyScalable = style->smoothScalable; @@ -976,7 +976,7 @@ QFontEngine *loadSingleEngine(int script, + qPrintable(def.family), script); if (engine->ref.loadRelaxed() == 0) delete engine; - return 0; + return nullptr; } engine->isSmoothlyScalable = style->smoothScalable; @@ -1081,9 +1081,9 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, Q_UNUSED(script); Q_UNUSED(pitch); - desc->foundry = 0; - desc->style = 0; - desc->size = 0; + desc->foundry = nullptr; + desc->style = nullptr; + desc->size = nullptr; qCDebug(lcFontMatch, " REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count); @@ -1104,7 +1104,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, } int px = -1; - QtFontSize *size = 0; + QtFontSize *size = nullptr; // 1. see if we have an exact matching size if (!(styleStrategy & QFont::ForceOutline)) { @@ -1244,10 +1244,10 @@ static int match(int script, const QFontDef &request, foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch); - desc->family = 0; - desc->foundry = 0; - desc->style = 0; - desc->size = 0; + desc->family = nullptr; + desc->foundry = nullptr; + desc->style = nullptr; + desc->size = nullptr; unsigned int score = ~0u; @@ -1280,7 +1280,7 @@ static int match(int script, const QFontDef &request, bestFoundry(script, score, request.styleStrategy, test.family, foundry_name, styleKey, request.pixelSize, pitch, &test, request.styleName); - if (test.foundry == 0 && !foundry_name.isEmpty()) { + if (test.foundry == nullptr && !foundry_name.isEmpty()) { // the specific foundry was not found, so look for // any foundry matching our requirements newscore = bestFoundry(script, score, request.styleStrategy, test.family, @@ -2068,7 +2068,7 @@ bool QFontDatabase::isPrivateFamily(const QString &family) const */ QString QFontDatabase::writingSystemName(WritingSystem writingSystem) { - const char *name = 0; + const char *name = nullptr; switch (writingSystem) { case Any: name = QT_TRANSLATE_NOOP("QFontDatabase", "Any"); @@ -2548,7 +2548,7 @@ QStringList QFontDatabase::applicationFontFamilies(int id) QFont QFontDatabase::systemFont(QFontDatabase::SystemFont type) { - const QFont *font = 0; + const QFont *font = nullptr; if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { switch (type) { case GeneralFont: @@ -2825,7 +2825,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script) if (fe->type() == QFontEngine::Box && !req.families.at(0).isEmpty()) { if (fe->ref.loadRelaxed() == 0) delete fe; - fe = 0; + fe = nullptr; } else { if (d->dpi > 0) fe->fontDef.pointSize = qreal(double((fe->fontDef.pixelSize * 72) / d->dpi)); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 1668fac5a3..3ca9e9bbde 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -221,7 +221,7 @@ static bool qt_get_font_table_default(void *user_data, uint tag, uchar *buffer, #ifdef QT_BUILD_INTERNAL // for testing purpose only, not thread-safe! -static QList *enginesCollector = 0; +static QList *enginesCollector = nullptr; Q_AUTOTEST_EXPORT void QFontEngine_startCollectingEngines() { @@ -234,7 +234,7 @@ Q_AUTOTEST_EXPORT QList QFontEngine_stopCollectingEngines() Q_ASSERT(enginesCollector); QList ret = *enginesCollector; delete enginesCollector; - enginesCollector = 0; + enginesCollector = nullptr; return ret; } #endif // QT_BUILD_INTERNAL @@ -569,9 +569,9 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) { glyph_metrics_t gi = boundingBox(glyph); - if (leftBearing != 0) + if (leftBearing != nullptr) *leftBearing = gi.leftBearing().toReal(); - if (rightBearing != 0) + if (rightBearing != nullptr) *rightBearing = gi.rightBearing().toReal(); } @@ -1022,7 +1022,7 @@ QByteArray QFontEngine::getSfntTable(uint tag) const { QByteArray table; uint len = 0; - if (!getSfntTableData(tag, 0, &len)) + if (!getSfntTableData(tag, nullptr, &len)) return table; table.resize(len); if (!getSfntTableData(tag, reinterpret_cast(table.data()), &len)) @@ -1231,11 +1231,11 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy // version check quint16 version; if (!qSafeFromBigEndian(header, endPtr, &version) || version != 0) - return 0; + return nullptr; quint16 numTables; if (!qSafeFromBigEndian(header + 2, endPtr, &numTables)) - return 0; + return nullptr; const uchar *maps = table + 4; @@ -1255,11 +1255,11 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy for (int n = 0; n < numTables; ++n) { quint16 platformId; if (!qSafeFromBigEndian(maps + 8 * n, endPtr, &platformId)) - return 0; + return nullptr; quint16 platformSpecificId = 0; if (!qSafeFromBigEndian(maps + 8 * n + 2, endPtr, &platformSpecificId)) - return 0; + return nullptr; switch (platformId) { case 0: // Unicode @@ -1309,38 +1309,38 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy } } if(tableToUse < 0) - return 0; + return nullptr; resolveTable: *isSymbolFont = (symbolTable > -1); quint32 unicode_table = 0; if (!qSafeFromBigEndian(maps + 8 * tableToUse + 4, endPtr, &unicode_table)) - return 0; + return nullptr; if (!unicode_table) - return 0; + return nullptr; // get the header of the unicode table header = table + unicode_table; quint16 format; if (!qSafeFromBigEndian(header, endPtr, &format)) - return 0; + return nullptr; quint32 length; if (format < 8) { quint16 tmp; if (!qSafeFromBigEndian(header + 2, endPtr, &tmp)) - return 0; + return nullptr; length = tmp; } else { if (!qSafeFromBigEndian(header + 4, endPtr, &length)) - return 0; + return nullptr; } if (table + unicode_table + length > endPtr) - return 0; + return nullptr; *cmapSize = length; // To support symbol fonts that contain a unicode table for the symbol area @@ -1844,7 +1844,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) return engine; } - return 0; + return nullptr; } glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const @@ -1865,7 +1865,7 @@ glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const const_cast(this)->ensureEngineAt(x); engine = m_engines.at(x); } - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == Box) continue; @@ -1934,7 +1934,7 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, if (!engine) continue; } - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == Box) continue; @@ -2308,7 +2308,7 @@ QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosit */ QFontEngine *QFontEngineMulti::createMultiFontEngine(QFontEngine *fe, int script) { - QFontEngine *engine = 0; + QFontEngine *engine = nullptr; QFontCache::Key key(fe->fontDef, script, /*multi = */true); QFontCache *fc = QFontCache::instance(); // We can't rely on the fontDef (and hence the cache Key) diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp index 409176d41b..d22239c040 100644 --- a/src/gui/text/qfontengine_qpf2.cpp +++ b/src/gui/text/qfontengine_qpf2.cpp @@ -151,17 +151,17 @@ static inline const uchar *verifyTag(const uchar *tagPtr, const uchar *endPtr) const QFontEngineQPF2::Glyph *QFontEngineQPF2::findGlyph(glyph_t g) const { if (!g || g >= glyphMapEntries) - return 0; + return nullptr; const quint32 *gmapPtr = reinterpret_cast(fontData + glyphMapOffset); quint32 glyphPos = qFromBigEndian(gmapPtr[g]); if (glyphPos > glyphDataSize) { if (glyphPos == 0xffffffff) - return 0; + return nullptr; #if defined(DEBUG_FONTENGINE) qDebug() << "glyph" << g << "outside of glyphData, remapping font file"; #endif if (glyphPos > glyphDataSize) - return 0; + return nullptr; } return reinterpret_cast(fontData + glyphDataOffset + glyphPos); } @@ -230,7 +230,7 @@ QFontEngineQPF2::QFontEngineQPF2(const QFontDef &def, const QByteArray &data) { fontDef = def; cache_cost = 100; - cmap = 0; + cmap = nullptr; cmapOffset = 0; cmapSize = 0; glyphMapOffset = 0; diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 906047cdb4..a79957797d 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -282,7 +282,7 @@ bool QFontMetrics::operator ==(const QFontMetrics &other) const int QFontMetrics::ascent() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->ascent()); } @@ -301,7 +301,7 @@ int QFontMetrics::ascent() const int QFontMetrics::capHeight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->capHeight()); } @@ -318,7 +318,7 @@ int QFontMetrics::capHeight() const int QFontMetrics::descent() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->descent()); } @@ -332,7 +332,7 @@ int QFontMetrics::descent() const int QFontMetrics::height() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->ascent()) + qRound(engine->descent()); } @@ -346,7 +346,7 @@ int QFontMetrics::height() const int QFontMetrics::leading() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->leading()); } @@ -360,7 +360,7 @@ int QFontMetrics::leading() const int QFontMetrics::lineSpacing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()); } @@ -377,7 +377,7 @@ int QFontMetrics::lineSpacing() const int QFontMetrics::minLeftBearing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->minLeftBearing()); } @@ -394,7 +394,7 @@ int QFontMetrics::minLeftBearing() const int QFontMetrics::minRightBearing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->minRightBearing()); } @@ -404,7 +404,7 @@ int QFontMetrics::minRightBearing() const int QFontMetrics::maxWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->maxCharWidth()); } @@ -415,7 +415,7 @@ int QFontMetrics::maxWidth() const int QFontMetrics::xHeight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (d->capital == QFont::SmallCaps) return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent()); return qRound(engine->xHeight()); @@ -429,7 +429,7 @@ int QFontMetrics::xHeight() const int QFontMetrics::averageCharWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->averageCharWidth()); } @@ -450,7 +450,7 @@ bool QFontMetrics::inFontUcs4(uint ucs4) const { const int script = QChar::script(ucs4); QFontEngine *engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return false; return engine->canRender(ucs4); @@ -476,7 +476,7 @@ int QFontMetrics::leftBearing(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return 0; @@ -509,7 +509,7 @@ int QFontMetrics::rightBearing(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return 0; @@ -518,7 +518,7 @@ int QFontMetrics::rightBearing(QChar ch) const glyph_t glyph = engine->glyphIndex(ch.unicode()); qreal rb; - engine->getGlyphBearings(glyph, 0, &rb); + engine->getGlyphBearings(glyph, nullptr, &rb); return qRound(rb); } @@ -673,7 +673,7 @@ int QFontMetrics::horizontalAdvance(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -725,7 +725,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -800,7 +800,7 @@ QRect QFontMetrics::boundingRect(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -877,7 +877,7 @@ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &te QRectF rb; QRectF rr(rect); qt_format_text(QFont(d.data()), rr, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, - tabArrayLen, 0); + tabArrayLen, nullptr); return rb.toAlignedRect(); } @@ -994,7 +994,7 @@ QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, in int QFontMetrics::underlinePos() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->underlinePosition()); } @@ -1030,7 +1030,7 @@ int QFontMetrics::strikeOutPos() const int QFontMetrics::lineWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->lineThickness()); } @@ -1248,7 +1248,7 @@ bool QFontMetricsF::operator ==(const QFontMetricsF &other) const qreal QFontMetricsF::ascent() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->ascent().toReal(); } @@ -1267,7 +1267,7 @@ qreal QFontMetricsF::ascent() const qreal QFontMetricsF::capHeight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->capHeight().toReal(); } @@ -1285,7 +1285,7 @@ qreal QFontMetricsF::capHeight() const qreal QFontMetricsF::descent() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->descent().toReal(); } @@ -1299,7 +1299,7 @@ qreal QFontMetricsF::descent() const qreal QFontMetricsF::height() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return (engine->ascent() + engine->descent()).toReal(); } @@ -1314,7 +1314,7 @@ qreal QFontMetricsF::height() const qreal QFontMetricsF::leading() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->leading().toReal(); } @@ -1328,7 +1328,7 @@ qreal QFontMetricsF::leading() const qreal QFontMetricsF::lineSpacing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return (engine->leading() + engine->ascent() + engine->descent()).toReal(); } @@ -1345,7 +1345,7 @@ qreal QFontMetricsF::lineSpacing() const qreal QFontMetricsF::minLeftBearing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->minLeftBearing(); } @@ -1362,7 +1362,7 @@ qreal QFontMetricsF::minLeftBearing() const qreal QFontMetricsF::minRightBearing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->minRightBearing(); } @@ -1372,7 +1372,7 @@ qreal QFontMetricsF::minRightBearing() const qreal QFontMetricsF::maxWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->maxCharWidth(); } @@ -1383,7 +1383,7 @@ qreal QFontMetricsF::maxWidth() const qreal QFontMetricsF::xHeight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (d->capital == QFont::SmallCaps) return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal(); return engine->xHeight().toReal(); @@ -1397,7 +1397,7 @@ qreal QFontMetricsF::xHeight() const qreal QFontMetricsF::averageCharWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->averageCharWidth().toReal(); } @@ -1420,7 +1420,7 @@ bool QFontMetricsF::inFontUcs4(uint ucs4) const { const int script = QChar::script(ucs4); QFontEngine *engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return false; return engine->canRender(ucs4); @@ -1446,7 +1446,7 @@ qreal QFontMetricsF::leftBearing(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return 0; @@ -1479,7 +1479,7 @@ qreal QFontMetricsF::rightBearing(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return 0; @@ -1488,7 +1488,7 @@ qreal QFontMetricsF::rightBearing(QChar ch) const glyph_t glyph = engine->glyphIndex(ch.unicode()); qreal rb; - engine->getGlyphBearings(glyph, 0, &rb); + engine->getGlyphBearings(glyph, nullptr, &rb); return rb; } @@ -1608,7 +1608,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -1679,7 +1679,7 @@ QRectF QFontMetricsF::boundingRect(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -1758,7 +1758,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString& QRectF rb; qt_format_text(QFont(d.data()), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, - tabArrayLen, 0); + tabArrayLen, nullptr); return rb; } @@ -1877,7 +1877,7 @@ QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, q qreal QFontMetricsF::underlinePos() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->underlinePosition().toReal(); } @@ -1912,7 +1912,7 @@ qreal QFontMetricsF::strikeOutPos() const qreal QFontMetricsF::lineWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->lineThickness().toReal(); } diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 90322b24da..02e25bb6af 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -368,7 +368,7 @@ QFontEngine *QPlatformFontDatabase::fontEngine(const QByteArray &fontData, qreal Q_UNUSED(pixelSize); Q_UNUSED(hintingPreference); qWarning("This plugin does not support font engines created directly from font data"); - return 0; + return nullptr; } /*! diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index e04c8909f3..884525bd76 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -750,7 +750,7 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ int script = qt_script_for_writing_system(writingSystem); QFontEngine *fe = font_d->engineForScript(script); - if (fe != 0 && fe->type() == QFontEngine::Multi) { + if (fe != nullptr && fe->type() == QFontEngine::Multi) { QFontEngineMulti *multiEngine = static_cast(fe); fe = multiEngine->engine(0); @@ -770,7 +770,7 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ Q_ASSERT(fe); } - if (fe != 0) { + if (fe != nullptr) { rawFont.d.data()->setFontEngine(fe); rawFont.d.data()->hintingPreference = font.hintingPreference(); } @@ -795,7 +795,7 @@ void QRawFont::setPixelSize(qreal pixelSize) void QRawFontPrivate::loadFromData(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) { - Q_ASSERT(fontEngine == 0); + Q_ASSERT(fontEngine == nullptr); QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase(); setFontEngine(pfdb->fontEngine(fontData, pixelSize, hintingPreference)); diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 490e0b6b8f..e588b44efd 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -403,7 +403,7 @@ QSizeF QStaticText::size() const } QStaticTextPrivate::QStaticTextPrivate() - : textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0), + : textWidth(-1.0), items(nullptr), itemCount(0), glyphPool(nullptr), positionPool(nullptr), needsRelayout(true), useBackendOptimizations(false), textFormat(Qt::AutoText), untransformedCoordinates(false) { @@ -411,7 +411,7 @@ QStaticTextPrivate::QStaticTextPrivate() QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other) : text(other.text), font(other.font), textWidth(other.textWidth), matrix(other.matrix), - items(0), itemCount(0), glyphPool(0), positionPool(0), textOption(other.textOption), + items(nullptr), itemCount(0), glyphPool(nullptr), positionPool(nullptr), textOption(other.textOption), needsRelayout(true), useBackendOptimizations(other.useBackendOptimizations), textFormat(other.textFormat), untransformedCoordinates(other.untransformedCoordinates) { diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index cf584f6980..c345e89a21 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -321,7 +321,7 @@ QSyntaxHighlighter::QSyntaxHighlighter(QTextDocument *parent) */ QSyntaxHighlighter::~QSyntaxHighlighter() { - setDocument(0); + setDocument(nullptr); } /*! @@ -601,7 +601,7 @@ QTextBlockUserData *QSyntaxHighlighter::currentBlockUserData() const { Q_D(const QSyntaxHighlighter); if (!d->currentBlock.isValid()) - return 0; + return nullptr; return d->currentBlock.userData(); } diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index c88497840f..b69b94d4e7 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -371,7 +371,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor int newPosition = position; - if (mode == QTextCursor::KeepAnchor && complexSelectionTable() != 0) { + if (mode == QTextCursor::KeepAnchor && complexSelectionTable() != nullptr) { if ((op >= QTextCursor::EndOfLine && op <= QTextCursor::NextWord) || (op >= QTextCursor::Right && op <= QTextCursor::WordRight)) { QTextTable *t = qobject_cast(priv->frameAt(position)); @@ -671,7 +671,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor QTextTable *QTextCursorPrivate::complexSelectionTable() const { if (position == anchor) - return 0; + return nullptr; QTextTable *t = qobject_cast(priv->frameAt(position)); if (t) { @@ -681,7 +681,7 @@ QTextTable *QTextCursorPrivate::complexSelectionTable() const Q_ASSERT(cell_anchor.isValid()); if (cell_pos == cell_anchor) - t = 0; + t = nullptr; } return t; } @@ -1044,7 +1044,7 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ Constructs a null cursor. */ QTextCursor::QTextCursor() - : d(0) + : d(nullptr) { } @@ -1623,7 +1623,7 @@ bool QTextCursor::hasComplexSelection() const if (!d) return false; - return d->complexSelectionTable() != 0; + return d->complexSelectionTable() != nullptr; } /*! @@ -2111,7 +2111,7 @@ QTextList *QTextCursor::insertList(QTextListFormat::Style style) QTextList *QTextCursor::createList(const QTextListFormat &format) { if (!d || !d->priv) - return 0; + return nullptr; QTextList *list = static_cast(d->priv->createObject(format)); QTextBlockFormat modifier; @@ -2146,7 +2146,7 @@ QTextList *QTextCursor::createList(QTextListFormat::Style style) QTextList *QTextCursor::currentList() const { if (!d || !d->priv) - return 0; + return nullptr; QTextBlockFormat b = blockFormat(); QTextObject *o = d->priv->objectForFormat(b); @@ -2186,7 +2186,7 @@ QTextTable *QTextCursor::insertTable(int rows, int cols) QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat &format) { if(!d || !d->priv || rows == 0 || cols == 0) - return 0; + return nullptr; int pos = d->position; QTextTable *t = QTextTablePrivate::createTable(d->priv, d->position, rows, cols, format); @@ -2206,7 +2206,7 @@ QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat QTextTable *QTextCursor::currentTable() const { if(!d || !d->priv) - return 0; + return nullptr; QTextFrame *frame = d->priv->frameAt(d->position); while (frame) { @@ -2215,7 +2215,7 @@ QTextTable *QTextCursor::currentTable() const return table; frame = frame->parentFrame(); } - return 0; + return nullptr; } /*! @@ -2230,7 +2230,7 @@ QTextTable *QTextCursor::currentTable() const QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format) { if (!d || !d->priv) - return 0; + return nullptr; return d->priv->insertFrame(selectionStart(), selectionEnd(), format); } @@ -2243,7 +2243,7 @@ QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format) QTextFrame *QTextCursor::currentFrame() const { if(!d || !d->priv) - return 0; + return nullptr; return d->priv->frameAt(d->position); } @@ -2603,7 +2603,7 @@ QTextDocument *QTextCursor::document() const { if (d->priv) return d->priv->document(); - return 0; // document went away + return nullptr; // document went away } QT_END_NAMESPACE diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index e94f635651..3382ec0b69 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1666,7 +1666,7 @@ QTextCursor QTextDocument::find(const QRegularExpression &expr, const QTextCurso */ QTextObject *QTextDocument::createObject(const QTextFormat &f) { - QTextObject *obj = 0; + QTextObject *obj = nullptr; if (f.isListFormat()) obj = new QTextList(this); else if (f.isTableFormat()) @@ -2408,7 +2408,7 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) sizeof("small") + sizeof("medium") + 1, // "x-large" )> compressed into "xx-large" sizeof("small") + sizeof("medium"), // "xx-large" ) }; - const char *name = 0; + const char *name = nullptr; const int idx = format.intProperty(QTextFormat::FontSizeAdjustment) + 1; if (idx >= 0 && idx <= 4) { name = sizeNameData + sizeNameOffsets[idx]; @@ -3256,7 +3256,7 @@ void QTextHtmlExporter::emitFrame(const QTextFrame::Iterator &frameIt) QTextFrame::Iterator next = frameIt; ++next; if (next.atEnd() - && frameIt.currentFrame() == 0 + && frameIt.currentFrame() == nullptr && frameIt.parentFrame() != doc->rootFrame() && frameIt.currentBlock().begin().atEnd()) return; diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 2f02f62a57..524931ebde 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -185,7 +185,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() docChangeOldLength(0), docChangeLength(0), framesDirty(true), - rtFrame(0), + rtFrame(nullptr), initialBlockCharFormatIndex(-1) // set correctly later in init() { editBlock = 0; @@ -195,7 +195,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() undoState = 0; revision = -1; // init() inserts a block, bringing it to 0 - lout = 0; + lout = nullptr; modified = false; modifiedState = 0; @@ -272,7 +272,7 @@ void QTextDocumentPrivate::clear() blocks.clear(); cachedResources.clear(); delete rtFrame; - rtFrame = 0; + rtFrame = nullptr; init(); cursors = oldCursors; { @@ -290,7 +290,7 @@ void QTextDocumentPrivate::clear() QTextDocumentPrivate::~QTextDocumentPrivate() { for (QTextCursorPrivate *curs : qAsConst(cursors)) - curs->priv = 0; + curs->priv = nullptr; cursors.clear(); undoState = 0; undoEnabled = true; @@ -643,7 +643,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O // qDebug("remove_block at %d", key); Q_ASSERT(X->size_array[0] == 1 && isValidBlockSeparator(text.at(X->stringPosition))); b = blocks.previous(b); - B = 0; + B = nullptr; c.command = blocks.size(b) == 1 ? QTextUndoCommand::BlockDeleted : QTextUndoCommand::BlockRemoved; w = remove_block(key, &c.blockFormat, QTextUndoCommand::BlockAdded, op); @@ -1437,7 +1437,7 @@ static QTextFrame *findChildFrame(QTextFrame *f, int pos) else return c; } - return 0; + return nullptr; } QTextFrame *QTextDocumentPrivate::rootFrame() const @@ -1467,7 +1467,7 @@ void QTextDocumentPrivate::clearFrame(QTextFrame *f) for (int i = 0; i < f->d_func()->childFrames.count(); ++i) clearFrame(f->d_func()->childFrames.at(i)); f->d_func()->childFrames.clear(); - f->d_func()->parentFrame = 0; + f->d_func()->parentFrame = nullptr; } void QTextDocumentPrivate::scan_frames(int pos, int charsRemoved, int charsAdded) @@ -1551,7 +1551,7 @@ QTextFrame *QTextDocumentPrivate::insertFrame(int start, int end, const QTextFra Q_ASSERT(start <= end || end == -1); if (start != end && frameAt(start) != frameAt(end)) - return 0; + return nullptr; beginEditBlock(); @@ -1599,7 +1599,7 @@ void QTextDocumentPrivate::removeFrame(QTextFrame *frame) QTextObject *QTextDocumentPrivate::objectForIndex(int objectIndex) const { if (objectIndex < 0) - return 0; + return nullptr; QTextObject *object = objects.value(objectIndex, 0); if (!object) { diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 742c56382d..d7bc707491 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -277,7 +277,7 @@ void QTextDocumentFragmentPrivate::insert(QTextCursor &_cursor) const \sa isEmpty() */ QTextDocumentFragment::QTextDocumentFragment() - : d(0) + : d(nullptr) { } @@ -287,7 +287,7 @@ QTextDocumentFragment::QTextDocumentFragment() like the document's title. */ QTextDocumentFragment::QTextDocumentFragment(const QTextDocument *document) - : d(0) + : d(nullptr) { if (!document) return; @@ -304,7 +304,7 @@ QTextDocumentFragment::QTextDocumentFragment(const QTextDocument *document) \sa isEmpty(), QTextCursor::selection() */ QTextDocumentFragment::QTextDocumentFragment(const QTextCursor &cursor) - : d(0) + : d(nullptr) { if (!cursor.hasSelection()) return; @@ -678,7 +678,7 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes() if (n->parent) n = &at(n->parent); else - n = 0; + n = nullptr; } } @@ -793,7 +793,7 @@ bool QTextHtmlImporter::closeTag() bool blockTagClosed = false; while (depth > endDepth) { - Table *t = 0; + Table *t = nullptr; if (!tables.isEmpty()) t = &tables.last(); @@ -816,7 +816,7 @@ bool QTextHtmlImporter::closeTag() indent = t->lastIndent; tables.resize(tables.size() - 1); - t = 0; + t = nullptr; if (tables.isEmpty()) { cursor = doc->rootFrame()->lastCursorPosition(); @@ -1123,7 +1123,7 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode() // for list items we may want to collapse with the bottom margin of the // list. - const QTextHtmlParserNode *parentNode = currentNode->parent ? &at(currentNode->parent) : 0; + const QTextHtmlParserNode *parentNode = currentNode->parent ? &at(currentNode->parent) : nullptr; if ((currentNode->id == Html_li || currentNode->id == Html_dt || currentNode->id == Html_dd) && parentNode && (parentNode->isListStart() || parentNode->id == Html_dl) @@ -1270,7 +1270,7 @@ void QTextHtmlImporter::appendBlock(const QTextBlockFormat &format, QTextCharFor QTextDocumentFragment QTextDocumentFragment::fromHtml(const QString &html) { - return fromHtml(html, 0); + return fromHtml(html, nullptr); } /*! diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index ed23a4d8d9..e21a8d8d52 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -111,7 +111,7 @@ public: QTextFrameData::QTextFrameData() : maximumWidth(QFIXED_MAX), - currentLayoutStruct(0), sizeDirty(true), layoutDirty(true) + currentLayoutStruct(nullptr), sizeDirty(true), layoutDirty(true) { } @@ -571,7 +571,7 @@ public: void setCellPosition(QTextTable *t, const QTextTableCell &cell, const QPointF &pos); QRectF layoutTable(QTextTable *t, int layoutFrom, int layoutTo, QFixed parentY); - void positionFloat(QTextFrame *frame, QTextLine *currentLine = 0); + void positionFloat(QTextFrame *frame, QTextLine *currentLine = nullptr); // calls the next one QRectF layoutFrame(QTextFrame *f, int layoutFrom, int layoutTo, QFixed parentY = 0); @@ -1554,7 +1554,7 @@ static inline double prioritizedEdgeAnchorOffset(const QTextDocumentLayoutPrivat competingCell = adjacentCell(table, cell, orthogonalEdge); if (competingCell.isValid()) { checkJoinedEdge(table, td, competingCell, edgeData.edge, edgeData, couldHaveContinuation, - &maxCompetingEdgeData, 0); + &maxCompetingEdgeData, nullptr); } } @@ -1946,7 +1946,7 @@ void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *paint QTextFrame::Iterator it, const QList &floats, QTextBlock *cursorBlockNeedingRepaint) const { Q_Q(const QTextDocumentLayout); - const bool inRootFrame = (!it.atEnd() && it.parentFrame() && it.parentFrame()->parentFrame() == 0); + const bool inRootFrame = (!it.atEnd() && it.parentFrame() && it.parentFrame()->parentFrame() == nullptr); QVector::ConstIterator lastVisibleCheckPoint = checkPoints.end(); if (inRootFrame && context.clip.isValid()) { @@ -1954,7 +1954,7 @@ void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *paint } QTextBlock previousBlock; - QTextFrame *previousFrame = 0; + QTextFrame *previousFrame = nullptr; for (; !it.atEnd(); ++it) { QTextFrame *c = it.currentFrame(); @@ -2050,7 +2050,7 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain QVector selections; int blpos = bl.position(); int bllen = bl.length(); - const QTextCharFormat *selFormat = 0; + const QTextCharFormat *selFormat = nullptr; for (int i = 0; i < context.selections.size(); ++i) { const QAbstractTextDocumentLayout::Selection &range = context.selections.at(i); const int selStart = range.cursor.selectionStart() - blpos; @@ -2920,7 +2920,7 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in QTextFrameFormat fformat = f->frameFormat(); QTextFrame *parent = f->parentFrame(); - const QTextFrameData *pd = parent ? data(parent) : 0; + const QTextFrameData *pd = parent ? data(parent) : nullptr; const qreal maximumWidth = qMax(qreal(0), pd ? pd->contentsWidth.toReal() : document->pageSize().width()); QFixed width = QFixed::fromReal(fformat.width().value(maximumWidth)); @@ -2971,7 +2971,7 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in } QTextFrame *parent = f->parentFrame(); - const QTextFrameData *pd = parent ? data(parent) : 0; + const QTextFrameData *pd = parent ? data(parent) : nullptr; // accumulate top and bottom margins if (parent) { @@ -3296,7 +3296,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout const QFixed origMaximumWidth = layoutStruct->maximumWidth; layoutStruct->maximumWidth = 0; - const QTextBlockFormat *previousBlockFormatPtr = 0; + const QTextBlockFormat *previousBlockFormatPtr = nullptr; if (lastIt.currentBlock().isValid()) previousBlockFormatPtr = &previousBlockFormat; @@ -3405,7 +3405,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout } - fd->currentLayoutStruct = 0; + fd->currentLayoutStruct = nullptr; } static inline void getLineHeightParams(const QTextBlockFormat &blockFormat, const QTextLine &line, qreal scaling, @@ -3865,7 +3865,7 @@ int QTextDocumentLayout::hitTest(const QPointF &point, Qt::HitTestAccuracy accur d->ensureLayouted(QFixed::fromReal(point.y())); QTextFrame *f = d->docPrivate->rootFrame(); int position = 0; - QTextLayout *l = 0; + QTextLayout *l = nullptr; QFixedPoint pointf; pointf.x = QFixed::fromReal(point.x()); pointf.y = QFixed::fromReal(point.y()); @@ -3944,7 +3944,7 @@ void QTextDocumentLayout::positionInlineObject(QTextInlineObject item, int posIn line = b.layout()->lineAt(b.layout()->lineCount()-1); // qDebug() << "layoutObject: line.isValid" << line.isValid() << b.position() << b.length() << // frame->firstPosition() << frame->lastPosition(); - d->positionFloat(frame, line.isValid() ? &line : 0); + d->positionFloat(frame, line.isValid() ? &line : nullptr); } void QTextDocumentLayout::drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item, diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp index 193d2c0dd3..0bafa5d9ff 100644 --- a/src/gui/text/qtextdocumentwriter.cpp +++ b/src/gui/text/qtextdocumentwriter.cpp @@ -107,7 +107,7 @@ public: \internal */ QTextDocumentWriterPrivate::QTextDocumentWriterPrivate(QTextDocumentWriter *qq) - : device(0), + : device(nullptr), deleteDevice(false), #if QT_CONFIG(textcodec) codec(QTextCodec::codecForName("utf-8")), @@ -320,7 +320,7 @@ bool QTextDocumentWriter::write(const QTextDocument *document) */ bool QTextDocumentWriter::write(const QTextDocumentFragment &fragment) { - if (fragment.d == 0) + if (fragment.d == nullptr) return false; // invalid fragment. QTextDocument *doc = fragment.d->doc; if (doc) @@ -337,7 +337,7 @@ bool QTextDocumentWriter::write(const QTextDocumentFragment &fragment) #if QT_CONFIG(textcodec) void QTextDocumentWriter::setCodec(QTextCodec *codec) { - if (codec == 0) + if (codec == nullptr) codec = QTextCodec::codecForName("UTF-8"); Q_ASSERT(codec); d->codec = codec; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 8a91b34b7a..0024f070ea 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -72,7 +72,7 @@ public: : m_string(string), m_analysis(analysis), m_items(items), - m_splitter(0) + m_splitter(nullptr) { } ~Itemizer() @@ -138,7 +138,7 @@ private: if (!m_splitter) m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, m_string.constData(), m_string.length(), - /*buffer*/0, /*buffer size*/0); + /*buffer*/nullptr, /*buffer size*/0); m_splitter->setPosition(start); QScriptAnalysis itemAnalysis = m_analysis[start]; @@ -1680,8 +1680,8 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, QGlyphLayout g = availableGlyphs(&si).mid(glyphs_shaped, num_glyphs); ushort *log_clusters = logClusters(&si) + item_pos; - hb_glyph_info_t *infos = hb_buffer_get_glyph_infos(buffer, 0); - hb_glyph_position_t *positions = hb_buffer_get_glyph_positions(buffer, 0); + hb_glyph_info_t *infos = hb_buffer_get_glyph_infos(buffer, nullptr); + hb_glyph_position_t *positions = hb_buffer_get_glyph_positions(buffer, nullptr); uint str_pos = 0; uint last_cluster = ~0u; uint last_glyph_pos = glyphs_shaped; @@ -1917,12 +1917,12 @@ void QTextEngine::init(QTextEngine *e) e->visualMovement = false; e->delayDecorations = false; - e->layoutData = 0; + e->layoutData = nullptr; e->minWidth = 0; e->maxWidth = 0; - e->specialData = 0; + e->specialData = nullptr; e->stackEngine = false; #ifndef QT_NO_RAWFONT e->useRawFont = false; @@ -1956,7 +1956,7 @@ const QCharAttributes *QTextEngine::attributes() const itemize(); if (! ensureSpace(layoutData->string.length())) - return NULL; + return nullptr; QVarLengthArray scriptItems(layoutData->items.size()); for (int i = 0; i < layoutData->items.size(); ++i) { @@ -2148,7 +2148,7 @@ void QTextEngine::itemize() const if (it == end || format != frag->format) { if (s && position >= s->preeditPosition) { position += s->preeditText.length(); - s = 0; + s = nullptr; } Q_ASSERT(position <= length); QFont::Capitalization capitalization = @@ -2443,8 +2443,8 @@ QTextEngine::FontEngineCache::FontEngineCache() //input is common (and hard to cache at a higher level) QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent, QFixed *leading) const { - QFontEngine *engine = 0; - QFontEngine *scaledEngine = 0; + QFontEngine *engine = nullptr; + QFontEngine *scaledEngine = nullptr; int script = si.analysis.script; QFont font = fnt; @@ -2459,7 +2459,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix engine->ref.ref(); if (feCache.prevScaledFontEngine) { releaseCachedFontEngine(feCache.prevScaledFontEngine); - feCache.prevScaledFontEngine = 0; + feCache.prevScaledFontEngine = nullptr; } } if (si.analysis.flags == QScriptAnalysis::SmallCaps) { @@ -2538,7 +2538,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix feCache.prevScript = script; feCache.prevPosition = -1; feCache.prevLength = -1; - feCache.prevScaledFontEngine = 0; + feCache.prevScaledFontEngine = nullptr; } } @@ -2808,14 +2808,14 @@ void QScriptLine::setDefaultHeight(QTextEngine *eng) QTextEngine::LayoutData::LayoutData() { - memory = 0; + memory = nullptr; allocated = 0; memory_on_stack = false; used = 0; hasBidi = false; layoutState = LayoutEmpty; haveCharAttributes = false; - logClustersPtr = 0; + logClustersPtr = nullptr; available_glyphs = 0; } @@ -2833,8 +2833,8 @@ QTextEngine::LayoutData::LayoutData(const QString &str, void **stack_memory, int allocated = 0; memory_on_stack = false; - memory = 0; - logClustersPtr = 0; + memory = nullptr; + logClustersPtr = nullptr; } else { memory_on_stack = true; memory = stack_memory; @@ -2855,7 +2855,7 @@ QTextEngine::LayoutData::~LayoutData() { if (!memory_on_stack) free(memory); - memory = 0; + memory = nullptr; } bool QTextEngine::LayoutData::reallocate(int totalGlyphs) @@ -2879,7 +2879,7 @@ bool QTextEngine::LayoutData::reallocate(int totalGlyphs) return false; } - void **newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *)); + void **newMem = (void **)::realloc(memory_on_stack ? nullptr : memory, newAllocated*sizeof(void *)); if (!newMem) { layoutState = LayoutFailed; return false; @@ -2928,7 +2928,7 @@ void QTextEngine::freeMemory() { if (!stackEngine) { delete layoutData; - layoutData = 0; + layoutData = nullptr; } else { layoutData->used = 0; layoutData->hasBidi = false; @@ -3035,7 +3035,7 @@ void QTextEngine::setPreeditArea(int position, const QString &preeditText) return; if (specialData->formats.isEmpty()) { delete specialData; - specialData = 0; + specialData = nullptr; } else { specialData->preeditText = QString(); specialData->preeditPosition = -1; @@ -3057,7 +3057,7 @@ void QTextEngine::setFormats(const QVector &formats) return; if (specialData->preeditText.isEmpty()) { delete specialData; - specialData = 0; + specialData = nullptr; } else { specialData->formats.clear(); } @@ -4004,7 +4004,7 @@ QTextLineItemIterator::QTextLineItemIterator(QTextEngine *_eng, int _lineNum, co const QTextLayout::FormatRange *_selection) : eng(_eng), line(eng->lines[_lineNum]), - si(0), + si(nullptr), lineNum(_lineNum), lineEnd(line.from + line.length), firstItem(eng->findItem(line.from)), diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index b867f42480..3b9f2d253e 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -463,7 +463,7 @@ static const QTextHtmlElement *lookupElementHelper(const QString &element) const QTextHtmlElement *end = &elements[Html_NumElements]; const QTextHtmlElement *e = std::lower_bound(start, end, element); if ((e == end) || (element < *e)) - return 0; + return nullptr; return e; } @@ -519,7 +519,7 @@ void QTextHtmlParser::dumpHtml() QTextHtmlParserNode *QTextHtmlParser::newNode(int parent) { QTextHtmlParserNode *lastNode = &nodes.last(); - QTextHtmlParserNode *newNode = 0; + QTextHtmlParserNode *newNode = nullptr; bool reuseLastNode = true; @@ -2123,7 +2123,7 @@ QVector QTextHtmlParser::declarationsForNode(int node) const QCss::StyleSelector::NodePtr n; n.id = node; - const char *extraPseudo = 0; + const char *extraPseudo = nullptr; if (nodes.at(node).id == Html_a && nodes.at(node).hasHref) extraPseudo = "link"; // Ensure that our own style is taken into consideration diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp index f7117bfe0a..14018f34da 100644 --- a/src/gui/text/qtextimagehandler.cpp +++ b/src/gui/text/qtextimagehandler.cpp @@ -246,7 +246,7 @@ QSizeF QTextImageHandler::intrinsicSize(QTextDocument *doc, int posInDocument, c QImage QTextImageHandler::image(QTextDocument *doc, const QTextImageFormat &imageFormat) { - Q_ASSERT(doc != 0); + Q_ASSERT(doc != nullptr); return getImage(doc, imageFormat); } diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index a3e194f835..fc256d72f3 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1649,7 +1649,7 @@ namespace { struct LineBreakHelper { LineBreakHelper() - : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(0), logClusters(0), + : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(nullptr), logClusters(nullptr), manualWrap(false), whiteSpaceOrObject(true) { } @@ -1705,7 +1705,7 @@ namespace { inline void calculateRightBearing(QFontEngine *engine, glyph_t glyph) { qreal rb; - engine->getGlyphBearings(glyph, 0, &rb); + engine->getGlyphBearings(glyph, nullptr, &rb); // We only care about negative right bearings, so we limit the range // of the bearing here so that we can assume it's negative in the rest @@ -2212,7 +2212,7 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine, int textPosition, int textLength) { - Q_ASSERT(logClusters != 0); + Q_ASSERT(logClusters != nullptr); QGlyphRun glyphRun; @@ -2593,7 +2593,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR } else { // si.isTab QFont f = eng->font(si); QTextItemInt gf(si, &f, format); - gf.chars = 0; + gf.chars = nullptr; gf.num_chars = 0; gf.width = iterator.itemWidth; QPainterPrivate::get(p)->drawTextItem(QPointF(iterator.x.toReal(), y.toReal()), gf, eng); diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index b845889c3d..77dcae0dc8 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -596,7 +596,7 @@ void QTextFramePrivate::remove_me() parentFrame->d_func()->childFrames.removeAt(index); childFrames.clear(); - parentFrame = 0; + parentFrame = nullptr; } /*! @@ -654,10 +654,10 @@ QTextFrame::iterator QTextFrame::end() const */ QTextFrame::iterator::iterator() { - f = 0; + f = nullptr; b = 0; e = 0; - cf = 0; + cf = nullptr; cb = 0; } @@ -669,7 +669,7 @@ QTextFrame::iterator::iterator(QTextFrame *frame, int block, int begin, int end) f = frame; b = begin; e = end; - cf = 0; + cf = nullptr; cb = block; } @@ -739,7 +739,7 @@ QTextFrame::iterator &QTextFrame::iterator::operator++() if (cf) { int end = cf->lastPosition() + 1; cb = map.findNode(end); - cf = 0; + cf = nullptr; } else if (cb) { cb = map.next(cb); if (cb == e) @@ -777,7 +777,7 @@ QTextFrame::iterator &QTextFrame::iterator::operator--() if (cf) { int start = cf->firstPosition() - 1; cb = map.findNode(start); - cf = 0; + cf = nullptr; } else { if (cb == b) goto end; @@ -907,7 +907,7 @@ QTextBlockUserData::~QTextBlockUserData() bool QTextBlock::isValid() const { - return p != 0 && p->blockMap().isValid(n); + return p != nullptr && p->blockMap().isValid(n); } /*! @@ -1079,7 +1079,7 @@ bool QTextBlock::contains(int position) const QTextLayout *QTextBlock::layout() const { if (!p || !n) - return 0; + return nullptr; const QTextBlockData *b = p->blockMap().fragment(n); if (!b->layout) diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 0e8666565f..408e3ec167 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -70,7 +70,7 @@ static QString pixelToPoint(qreal pixels) // strategies class QOutputStrategy { public: - QOutputStrategy() : contentStream(0), counter(1) { } + QOutputStrategy() : contentStream(nullptr), counter(1) { } virtual ~QOutputStrategy() {} virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes) = 0; @@ -240,7 +240,7 @@ void QTextOdfWriter::writeFrame(QXmlStreamWriter &writer, const QTextFrame *fram } QTextFrame::iterator iterator = frame->begin(); - QTextFrame *child = 0; + QTextFrame *child = nullptr; int tableRow = -1; while (! iterator.atEnd()) { @@ -437,7 +437,7 @@ static bool probeImageData(QIODevice *device, QImage *image, QString *mimeType, void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const { writer.writeStartElement(drawNS, QString::fromLatin1("frame")); - if (m_strategy == 0) { + if (m_strategy == nullptr) { // don't do anything. } else if (fragment.charFormat().isImageFormat()) { @@ -997,8 +997,8 @@ QTextOdfWriter::QTextOdfWriter(const QTextDocument &document, QIODevice *device) svgNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")), m_document(&document), m_device(device), - m_strategy(0), - m_codec(0), + m_strategy(nullptr), + m_codec(nullptr), m_createArchive(true) { } @@ -1093,7 +1093,7 @@ bool QTextOdfWriter::writeAll() writer.writeEndElement(); // document-content writer.writeEndDocument(); delete m_strategy; - m_strategy = 0; + m_strategy = nullptr; return true; } diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index 2c2c05567f..2f195599f0 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -62,7 +62,7 @@ QTextOption::QTextOption() unused2(0), f(0), tab(-1), - d(0) + d(nullptr) { direction = Qt::LayoutDirectionAuto; } @@ -80,7 +80,7 @@ QTextOption::QTextOption(Qt::Alignment alignment) unused2(0), f(0), tab(-1), - d(0) + d(nullptr) { direction = QGuiApplication::layoutDirection(); } @@ -107,7 +107,7 @@ QTextOption::QTextOption(const QTextOption &o) unused2(o.unused2), f(o.f), tab(o.tab), - d(0) + d(nullptr) { if (o.d) d = new QTextOptionPrivate(*o.d); @@ -124,7 +124,7 @@ QTextOption &QTextOption::operator=(const QTextOption &o) if (this == &o) return *this; - QTextOptionPrivate* dNew = 0; + QTextOptionPrivate* dNew = nullptr; if (o.d) dNew = new QTextOptionPrivate(*o.d); delete d; diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index fc7fbcac12..80c0f122e8 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -141,8 +141,8 @@ static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourc if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; + stream.zalloc = (alloc_func)nullptr; + stream.zfree = (free_func)nullptr; err = inflateInit2(&stream, -MAX_WBITS); if (err != Z_OK) @@ -172,9 +172,9 @@ static int deflate (Bytef *dest, ulong *destLen, const Bytef *source, ulong sour stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; + stream.zalloc = (alloc_func)nullptr; + stream.zfree = (free_func)nullptr; + stream.opaque = (voidpf)nullptr; err = deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY); if (err != Z_OK) return err; @@ -705,7 +705,7 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const } // TODO add a check if data.length() > contents.length(). Then try to store the original and revert the compression method to be uncompressed writeUInt(header.h.compressed_size, data.length()); - uint crc_32 = ::crc32(0, 0, 0); + uint crc_32 = ::crc32(0, nullptr, 0); crc_32 = ::crc32(crc_32, (const uchar *)contents.constData(), contents.length()); writeUInt(header.h.crc_32, crc_32); @@ -886,7 +886,7 @@ bool QZipReader::isReadable() const bool QZipReader::exists() const { QFile *f = qobject_cast (d->device); - if (f == 0) + if (f == nullptr) return true; return f->exists(); } @@ -1178,7 +1178,7 @@ bool QZipWriter::isWritable() const bool QZipWriter::exists() const { QFile *f = qobject_cast (d->device); - if (f == 0) + if (f == nullptr) return true; return f->exists(); } diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 99214c4960..763f309fc7 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -287,7 +287,7 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c */ void QDesktopServices::unsetUrlHandler(const QString &scheme) { - setUrlHandler(scheme, 0, 0); + setUrlHandler(scheme, nullptr, nullptr); } #if QT_DEPRECATED_SINCE(5, 0) diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 024f0f084e..4af5e47f8f 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -177,7 +177,7 @@ void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo, qreal extra = compare(box, totalBox, j); if (extra > 0.0) { calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(), - 0, totalBox, rowInfo, snapToPixelGrid); + nullptr, totalBox, rowInfo, snapToPixelGrid); for (int k = 0; k < span; ++k) extras[k].q_sizes(j) = newSizes[k]; @@ -988,7 +988,7 @@ void QGridLayoutEngine::removeItem(QGridLayoutItem *item) for (int i = item->firstRow(); i <= item->lastRow(); ++i) { for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) { if (itemAt(i, j) == item) - setItemAt(i, j, 0); + setItemAt(i, j, nullptr); } } @@ -1001,7 +1001,7 @@ QGridLayoutItem *QGridLayoutEngine::itemAt(int row, int column, Qt::Orientation if (orientation == Qt::Horizontal) qSwap(row, column); if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount())) - return 0; + return nullptr; return q_grid.at((row * internalGridColumnCount()) + column); } @@ -1100,7 +1100,7 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, if (constraintOrientation() == Qt::Vertical) { //We have items whose height depends on their width if (constraint.width() >= 0) { - ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); QVector sizehint_xx; QVector sizehint_widths; @@ -1110,14 +1110,14 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), - 0, sizehint_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, sizehint_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical, styleInfo); sizeHintCalculated = true; } } else { if (constraint.height() >= 0) { //We have items whose width depends on their height - ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); QVector sizehint_yy; QVector sizehint_heights; @@ -1127,7 +1127,7 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), - 0, sizehint_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); + nullptr, sizehint_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal, styleInfo); sizeHintCalculated = true; } @@ -1137,8 +1137,8 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, } //No items with height for width, so it doesn't matter which order we do these in - ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); - ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); return QSizeF(q_totalBoxes[Hor].q_sizes(which), q_totalBoxes[Ver].q_sizes(which)); } @@ -1650,18 +1650,18 @@ void QGridLayoutEngine::ensureGeometries(const QSizeF &size, if (constraintOrientation() != Qt::Horizontal) { //We might have items whose height depends on their width (HFW) - ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), - 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], q_xx.data(), q_widths.data(), Qt::Vertical, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), q_descents.data(), q_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); } else { //We have items whose width depends on their height (WFH) - ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), @@ -1669,7 +1669,7 @@ void QGridLayoutEngine::ensureGeometries(const QSizeF &size, ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], q_yy.data(), q_heights.data(), Qt::Horizontal, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), - 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); } } diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index ebf46f8e4e..41cbd1b15a 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -247,7 +247,7 @@ void QTextureFileData::setLogName(const QByteArray &name) static QByteArray glFormatName(quint32 fmt) { - const char *id = 0; + const char *id = nullptr; #if QT_CONFIG(opengl) id = QMetaEnum::fromType().valueToKey(fmt); #endif diff --git a/src/gui/vulkan/qvulkaninstance.cpp b/src/gui/vulkan/qvulkaninstance.cpp index 764cb917ad..4b961a6f20 100644 --- a/src/gui/vulkan/qvulkaninstance.cpp +++ b/src/gui/vulkan/qvulkaninstance.cpp @@ -758,7 +758,7 @@ VkSurfaceKHR QVulkanInstance::surfaceForWindow(QWindow *window) // VkSurfaceKHR is non-dispatchable and maps to a pointer on x64 and a uint64 on x86. // Therefore a pointer is returned from the platform plugin, not the value itself. void *p = nativeInterface->nativeResourceForWindow(QByteArrayLiteral("vkSurface"), window); - return p ? *static_cast(p) : 0; + return p ? *static_cast(p) : VK_NULL_HANDLE; } /*! diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp index 790bef9e14..ed73a77683 100644 --- a/src/gui/vulkan/qvulkanwindow.cpp +++ b/src/gui/vulkan/qvulkanwindow.cpp @@ -1866,7 +1866,7 @@ void QVulkanWindowPrivate::beginFrame() // build new draw command buffer if (image.cmdBuf) { devFuncs->vkFreeCommandBuffers(dev, cmdPool, 1, &image.cmdBuf); - image.cmdBuf = 0; + image.cmdBuf = nullptr; } VkCommandBufferAllocateInfo cmdBufInfo = { -- cgit v1.2.3 From 29adc0eed9b9dc3cce92f8acaaeaed3ab1bc6414 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 5 Dec 2019 16:45:31 +0100 Subject: Fix updating the text cursor position after editing In some cases when editing the text (for example when removing the selected text, or pasting a text block) the text cursor position is updated, but its visual x position is not updated. This causes the next cursor movements to start from a wrong position. Force the update for those cases. Fixes: QTBUG-78479 Change-Id: Ia496be62beec58660f5e1695e5aafae09c79684e Reviewed-by: Christian Ehrlicher --- src/gui/text/qtextcursor.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index c88497840f..056a854789 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -2261,6 +2261,7 @@ void QTextCursor::insertFragment(const QTextDocumentFragment &fragment) d->remove(); fragment.d->insert(*this); d->priv->endEditBlock(); + d->setX(); if (fragment.d && fragment.d->doc) d->priv->mergeCachedResources(fragment.d->doc->docHandle()); -- cgit v1.2.3 From 4d391514b075c65b33f55b2d1900f66e9bce985f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 6 Dec 2019 15:59:59 +0100 Subject: Fix crash on debug output of null QColorSpace Change-Id: I7d1d20d7dc2c5ac10dbe8d0a0b4111e8198bfabf Reviewed-by: Eirik Aavitsland --- src/gui/painting/qcolorspace.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp index 937bb505c9..9631fdb416 100644 --- a/src/gui/painting/qcolorspace.cpp +++ b/src/gui/painting/qcolorspace.cpp @@ -784,10 +784,12 @@ QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace) QDebugStateSaver saver(dbg); dbg.nospace(); dbg << "QColorSpace("; - if (colorSpace.d_ptr->namedColorSpace) - dbg << colorSpace.d_ptr->namedColorSpace << ", "; - dbg << colorSpace.primaries() << ", " << colorSpace.transferFunction(); - dbg << ", gamma=" << colorSpace.gamma(); + if (colorSpace.d_ptr) { + if (colorSpace.d_ptr->namedColorSpace) + dbg << colorSpace.d_ptr->namedColorSpace << ", "; + dbg << colorSpace.primaries() << ", " << colorSpace.transferFunction(); + dbg << ", gamma=" << colorSpace.gamma(); + } dbg << ')'; return dbg; } -- cgit v1.2.3 From 7be4bbcbc51f198cd1e1b40adaf310a04422ac1e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 9 Dec 2019 15:05:28 +0100 Subject: rhi: metal: Do not fail pipeline creation upon compiler warnings Change-Id: I39384de56d74cf9f1d345a5d395cc07030c6a2ab Fixes: QTBUG-80629 Reviewed-by: Eirik Aavitsland --- src/gui/rhi/qrhimetal.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 131b2da802..3ecc56d147 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -3149,7 +3149,10 @@ id QRhiMetalData::createMetalLib(const QShader &shader, QShader::Var [opts release]; // src is autoreleased - if (err) { + // if lib is null and err is non-null, we had errors (fail) + // if lib is non-null and err is non-null, we had warnings (success) + // if lib is non-null and err is null, there were no errors or warnings (success) + if (!lib) { const QString msg = QString::fromNSString(err.localizedDescription); *error = msg; return nil; -- cgit v1.2.3 From baed8534bc1dac36a9d0ef4240fc14398076a192 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 5 Nov 2019 14:06:46 +0100 Subject: Move the tooltip out of the way of very large mouse cursors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users that have large mouse pointers configured in their settings can not see tooltips, as they are obscured by the pointer. Native applications on Windows and macOS have the same problem, which includes the tooltips for the minimize/maximize/close controls in the window frame of e.g. Explorer. Introduce QPlatformCursor::size that returns a value that is based on the user's settings, or a default value. We can then use that value to move the tooltip out of the way. On Windows, the calculation of the cursor size is based on experimenting with the settings, which are in logical independent pixels. The placement of the tooltip attempts to keep existing behavior, and to not end up with a tooltip that's very far away from the tip of the arrow even for very large mouse cursors. [ChangeLog][QtWidgets][QToolTip] Make sure that the tooltip is not obscured by very large mouse pointers on Windows and macOS. Change-Id: I8e13b7a166bfe8b59cef4765c950f90fefeaef9d Fixes: QTBUG-79627 Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qplatformcursor.cpp | 8 ++++++++ src/gui/kernel/qplatformcursor.h | 1 + 2 files changed, 9 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index 49eff2ad23..aabf28a727 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -131,6 +131,14 @@ void QPlatformCursor::setPos(const QPoint &pos) QWindowSystemInterface::handleMouseEvent(0, pos, pos, Qt::NoButton, Qt::NoButton, QEvent::MouseMove); } +/*! + Returns the size of the cursor, in native pixels. +*/ +QSize QPlatformCursor::size() const +{ + return QSize(16, 16); +} + // End of display and pointer event handling code // Beginning of built-in cursor graphics // from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h index f36a73c861..f3871d8780 100644 --- a/src/gui/kernel/qplatformcursor.h +++ b/src/gui/kernel/qplatformcursor.h @@ -96,6 +96,7 @@ public: #endif // QT_NO_CURSOR virtual QPoint pos() const; virtual void setPos(const QPoint &pos); + virtual QSize size() const; static Capabilities capabilities() { return m_capabilities; } static void setCapabilities(Capabilities c) { m_capabilities = c; } -- cgit v1.2.3 From 53804f553d446c962764ba3365a8b390436fceb4 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 10 Dec 2019 10:43:53 +0100 Subject: rhi: gl: Destructure mat3 correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per std140 packing rules. Change-Id: I85663d36a9fa617ea387e8f201677471b2ebd948 Fixes: QTBUG-80655 Reviewed-by: Christian Strømme --- src/gui/rhi/qrhigles2.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 563d59b318..e4490ceedb 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2428,7 +2428,15 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC f->glUniformMatrix2fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast(src)); break; case QShaderDescription::Mat3: - f->glUniformMatrix3fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast(src)); + { + // 4 floats per column (or row, if row-major) + float mat[9]; + const float *srcMat = reinterpret_cast(src); + memcpy(mat, srcMat, 3 * sizeof(float)); + memcpy(mat + 3, srcMat + 4, 3 * sizeof(float)); + memcpy(mat + 6, srcMat + 8, 3 * sizeof(float)); + f->glUniformMatrix3fv(uniform.glslLocation, 1, GL_FALSE, mat); + } break; case QShaderDescription::Mat4: f->glUniformMatrix4fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast(src)); -- cgit v1.2.3 From e6de661a8aa96b5905ea7ba4cd5d76bd06da3f93 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 10 Dec 2019 10:52:03 +0100 Subject: rhi: gl: Handle struct and array of struct uniforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have intentionally limited support for advanced things like arrays in a uniform block. There is one very common case however: a one dimensional array of a struct. Typical example for Qt Quick 3D: struct LightSource { vec4 position; ... }; layout (std140, binding = 1) uniform cbBufferLights { int uNumLights; LightSource lights[MAX_NUM_LIGHTS]; }; With GLSL (uniform blocks disabled) this gets turned into two structs where one has a 'lights' member that is an array of the other struct. Teach the OpenGL backend of QRhi how to handle this. This makes the QRhi port of Qt Quick3D functional with the OpenGL backend as well. Change-Id: I6a09b93276794f7ecdd38f5bfbd3491a9ef58146 Fixes: QTBUG-80628 Reviewed-by: Christian Strømme --- src/gui/rhi/qrhigles2.cpp | 67 +++++++++++++++++++++++++++++++++++++-------- src/gui/rhi/qrhigles2_p_p.h | 9 +++++- 2 files changed, 63 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index e4490ceedb..3fb2ec38a7 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2927,21 +2927,64 @@ bool QRhiGles2::linkProgram(GLuint program) return true; } -void QRhiGles2::gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub, +void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable &var, + const QByteArray &namePrefix, + int binding, + int baseOffset, + GLuint program, + QVector *dst) +{ + if (var.type == QShaderDescription::Struct) { + qWarning("Nested structs are not supported at the moment. '%s' ignored.", + qPrintable(var.name)); + return; + } + QGles2UniformDescription uniform; + uniform.type = var.type; + const QByteArray name = namePrefix + var.name.toUtf8(); + uniform.glslLocation = f->glGetUniformLocation(program, name.constData()); + if (uniform.glslLocation >= 0) { + uniform.binding = binding; + uniform.offset = uint(baseOffset + var.offset); + uniform.size = var.size; + dst->append(uniform); + } +} + +void QRhiGles2::gatherUniforms(GLuint program, + const QShaderDescription::UniformBlock &ub, QVector *dst) { - const QByteArray prefix = ub.structName.toUtf8() + '.'; + QByteArray prefix = ub.structName.toUtf8() + '.'; for (const QShaderDescription::BlockVariable &blockMember : ub.members) { - // ### no array support for now - QGles2UniformDescription uniform; - uniform.type = blockMember.type; - const QByteArray name = prefix + blockMember.name.toUtf8(); - uniform.glslLocation = f->glGetUniformLocation(program, name.constData()); - if (uniform.glslLocation >= 0) { - uniform.binding = ub.binding; - uniform.offset = uint(blockMember.offset); - uniform.size = blockMember.size; - dst->append(uniform); + if (blockMember.type == QShaderDescription::Struct) { + prefix += blockMember.name.toUtf8(); + const int baseOffset = blockMember.offset; + if (blockMember.arrayDims.isEmpty()) { + for (const QShaderDescription::BlockVariable &structMember : blockMember.structMembers) + registerUniformIfActive(structMember, prefix, ub.binding, baseOffset, program, dst); + } else { + if (blockMember.arrayDims.count() > 1) { + qWarning("Array of struct '%s' has more than one dimension. Only the first dimension is used.", + qPrintable(blockMember.name)); + } + const int dim = blockMember.arrayDims.first(); + const int elemSize = blockMember.size / dim; + int elemOffset = baseOffset; + for (int di = 0; di < dim; ++di) { + const QByteArray arrayPrefix = prefix + '[' + QByteArray::number(di) + ']' + '.'; + for (const QShaderDescription::BlockVariable &structMember : blockMember.structMembers) + registerUniformIfActive(structMember, arrayPrefix, ub.binding, elemOffset, program, dst); + elemOffset += elemSize; + } + } + } else { + if (!blockMember.arrayDims.isEmpty()) { + qWarning("Arrays are only supported for structs at the moment. '%s' ignored.", + qPrintable(blockMember.name)); + continue; + } + registerUniformIfActive(blockMember, prefix, ub.binding, 0, program, dst); } } } diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index 0283fadb4e..4a98011d3d 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -706,7 +706,14 @@ public: QByteArray shaderSource(const QRhiShaderStage &shaderStage, int *glslVersion); bool compileShader(GLuint program, const QRhiShaderStage &shaderStage, int *glslVersion); bool linkProgram(GLuint program); - void gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub, + void registerUniformIfActive(const QShaderDescription::BlockVariable &var, + const QByteArray &namePrefix, + int binding, + int baseOffset, + GLuint program, + QVector *dst); + void gatherUniforms(GLuint program, + const QShaderDescription::UniformBlock &ub, QVector *dst); void gatherSamplers(GLuint program, const QShaderDescription::InOutVariable &v, QVector *dst); -- cgit v1.2.3 From 5a26bf9d65b75db3abefa967beb13b2510719bd5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 11 Dec 2019 09:30:26 +0100 Subject: Avoid initializing QFlags with 0 or nullptr in macOS-specific code It is being deprecated. Change-Id: If1b0b058140e197d41efae93025c4eefc2ed9bbd Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qfont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index e162015aba..9ede90d8de 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2707,7 +2707,7 @@ bool QFontInfo::fixedPitch() const QChar ch[2] = { QLatin1Char('i'), QLatin1Char('m') }; QGlyphLayoutArray<2> g; int l = 2; - if (!engine->stringToCMap(ch, 2, &g, &l, 0)) + if (!engine->stringToCMap(ch, 2, &g, &l, {})) Q_UNREACHABLE(); Q_ASSERT(l == 2); engine->fontDef.fixedPitch = g.advances[0] == g.advances[1]; -- cgit v1.2.3 From c3a66baff87e8d231aae06ccd1eb5d623587593d Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 10 Dec 2019 13:01:45 +0100 Subject: Move QOpenGLDebugLogger from QtGui to QtOpenGL Task-number: QTBUG-74409 Change-Id: Ida7a89b214cd5e1a3b6fdfa651299a9c5a654f5b Reviewed-by: Laszlo Agocs --- src/gui/opengl/opengl.pri | 2 - src/gui/opengl/qopengldebug.cpp | 1826 --------------------------------------- src/gui/opengl/qopengldebug.h | 221 ----- 3 files changed, 2049 deletions(-) delete mode 100644 src/gui/opengl/qopengldebug.cpp delete mode 100644 src/gui/opengl/qopengldebug.h (limited to 'src/gui') diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index 24758afdeb..9eab55f112 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -27,7 +27,6 @@ qtConfig(opengl) { opengl/qopenglversionfunctions.h \ opengl/qopenglversionfunctionsfactory_p.h \ opengl/qopenglvertexarrayobject.h \ - opengl/qopengldebug.h \ opengl/qopengltextureblitter.h \ opengl/qopengltexture.h \ opengl/qopengltexture_p.h \ @@ -53,7 +52,6 @@ qtConfig(opengl) { opengl/qopenglversionfunctions.cpp \ opengl/qopenglversionfunctionsfactory.cpp \ opengl/qopenglvertexarrayobject.cpp \ - opengl/qopengldebug.cpp \ opengl/qopengltextureblitter.cpp \ opengl/qopengltexture.cpp \ opengl/qopengltexturehelper.cpp \ diff --git a/src/gui/opengl/qopengldebug.cpp b/src/gui/opengl/qopengldebug.cpp deleted file mode 100644 index 310006feaf..0000000000 --- a/src/gui/opengl/qopengldebug.cpp +++ /dev/null @@ -1,1826 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#include "qopengldebug.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QOpenGLDebugMessage - \brief The QOpenGLDebugMessage class wraps an OpenGL debug message. - \inmodule QtGui - \reentrant - \since 5.1 - \ingroup shared - \ingroup painting-3D - - Debug messages are usually created by the OpenGL server and then read by - OpenGL clients (either from the OpenGL internal debug log, or logged in real-time). - A debug message has a textual representation, a vendor-specific numeric id, - a source, a type and a severity. - - It's also possible for applications or third-party libraries and toolkits - to create and insert messages in the debug log. In order to do so, you can use - the createApplicationMessage() or the createThirdPartyMessage() static functions. - - \sa QOpenGLDebugLogger -*/ - -/*! - \class QOpenGLDebugLogger - \brief The QOpenGLDebugLogger enables logging of OpenGL debugging messages. - \inmodule QtGui - \since 5.1 - \ingroup painting-3D - - \tableofcontents - - \section1 Introduction - - OpenGL programming can be very error prone. Most of the time, a single - failing call to OpenGL can cause an entire portion of an application to - stop working, with nothing being drawn on the screen. - - The only way to be sure that no errors are being returned from the OpenGL - implementation is checking with \c{glGetError} after each and every API - call. Moreover, OpenGL errors stack up, therefore glGetError should always - be used in a loop like this: - - \snippet code/src_gui_opengl_qopengldebug.cpp 0 - - If you try to clear the error stack, make sure not just keep going until - GL_NO_ERROR is returned but also break on GL_CONTEXT_LOST as that error - value will keep repeating. - - There are also many other information we are interested in (as application - developers), for instance performance issues, or warnings about using - deprecated APIs. Those kind of messages are not reported through the - ordinary OpenGL error reporting mechanisms. - - QOpenGLDebugLogger aims at addressing these issues by providing access to - the \e{OpenGL debug log}. If your OpenGL implementation supports it (by - exposing the \c{GL_KHR_debug} extension), messages from the OpenGL server - will be either logged in an internal OpenGL log, or passed in "real-time" - to listeners as they're generated from OpenGL. - - QOpenGLDebugLogger supports both these modes of operation. Refer to the - following sections to find out the differences between them. - - \section1 Creating an OpenGL Debug Context - - For efficiency reasons, OpenGL implementations are allowed not to create - any debug output at all, unless the OpenGL context is a debug context. In order - to create a debug context from Qt, you must set the QSurfaceFormat::DebugContext - format option on the QSurfaceFormat used to create the QOpenGLContext object: - - \snippet code/src_gui_opengl_qopengldebug.cpp 1 - - Note that requesting a 3.2 OpenGL Core Profile is just for the example's - purposes; this class is not tied to any specific OpenGL or OpenGL ES - version, as it relies on the availability of the \c{GL_KHR_debug} extension - (see below). - - \section1 Creating and Initializing a QOpenGLDebugLogger - - QOpenGLDebugLogger is a simple QObject-derived class. Just like all QObject - subclasses, you create an instance (and optionally specify a parent - object), and like the other OpenGL functions in Qt you \e{must} initialize - it before usage by calling initialize() whilst there is a current OpenGL context: - - \snippet code/src_gui_opengl_qopengldebug.cpp 2 - - Note that the \c{GL_KHR_debug} extension \e{must} be available in the context - in order to access the messages logged by OpenGL. You can check the - presence of this extension by calling: - - \snippet code/src_gui_opengl_qopengldebug.cpp 3 - - where \c{ctx} is a valid QOpenGLContext. If the extension is not available, - initialize() will return false. - - \section1 Reading the Internal OpenGL Debug Log - - OpenGL implementations keep an internal log of debug messages. Messages - stored in this log can be retrieved by using the loggedMessages() function: - - \snippet code/src_gui_opengl_qopengldebug.cpp 4 - - The internal log has a limited size; when it fills up, older messages will - get discarded to make room for the new incoming messages. When you call - loggedMessages(), the internal log will be emptied as well. - - If you want to be sure not to lose any debug message, you must use real-time - logging instead of calling this function. However, debug messages might - still be generated in the timespan between context creation and activation - of real-time logging (or, in general, when the real-time logging is disabled). - - \section1 Real-time logging of messages - - It is also possible to receive a stream of debug messages from the OpenGL - server \e{as they are generated} by the implementation. In order to do so, - you need to connect a suitable slot to the messageLogged() signal, and - start logging by calling startLogging(): - - \snippet code/src_gui_opengl_qopengldebug.cpp 5 - - Similarly, logging can be disabled at any time by calling the stopLogging() - function. - - Real-time logging can be either asynchronous or synchronous, depending on - the parameter passed to startLogging(). When logging in asynchronous mode - (the default, as it has a very small overhead), the OpenGL implementation - can generate messages at any time, and/or in an order which is different from the - order of the OpenGL commands which caused those messages to be logged. - The messages could also be generated from a thread that it's different from - the thread the context is currently bound to. This is because OpenGL - implementations are usually highly threaded and asynchronous, and therefore - no warranties are made about the relative order and the timings of the - debug messages. - - On the other hand, logging in synchronous mode has a high overhead, but - the OpenGL implementation guarantees that all the messages caused by a - certain command are received in order, before the command returns, - and from the same thread the OpenGL context is bound to. - - This means that when logging in synchronous mode you will be able to run - your OpenGL application in a debugger, put a breakpoint on a slot connected - to the messageLogged() signal, and see in the backtrace the exact call - that caused the logged message. This can be extremely useful to debug - an OpenGL problem. Note that if OpenGL rendering is happening in another - thread, you must force the signal/slot connection type to Qt::DirectConnection - in order to be able to see the actual backtrace. - - Refer to the LoggingMode enum documentation for more information about - logging modes. - - \note When real-time logging is enabled, debug messages will \e{not} be - inserted in the internal OpenGL debug log any more; messages already - present in the internal log will not be deleted, nor they will be emitted - through the messageLogged() signal. Since some messages might be generated - before real-time logging is started (and therefore be kept in the internal - OpenGL log), it is important to always check if it contains any message - after calling startLogging(). - - \section1 Inserting Messages in the Debug Log - - It is possible for applications and libraries to insert custom messages in - the debug log, for instance for marking a group of related OpenGL commands - and therefore being then able to identify eventual messages coming from them. - - In order to do so, you can create a QOpenGLDebugMessage object by calling - \l{QOpenGLDebugMessage::}{createApplicationMessage()} or - \l{QOpenGLDebugMessage::}{createThirdPartyMessage()}, and then inserting it - into the log by calling logMessage(): - - \snippet code/src_gui_opengl_qopengldebug.cpp 6 - - Note that OpenGL implementations have a vendor-specific limit to the length - of the messages that can be inserted in the debug log. You can retrieve - this length by calling the maximumMessageLength() method; messages longer - than the limit will automatically get truncated. - - \section1 Controlling the Debug Output - - QOpenGLDebugMessage is also able to apply filters to the debug messages, and - therefore limit the amount of messages logged. You can enable or disable - logging of messages by calling enableMessages() and disableMessages() - respectively. By default, all messages are logged. - - It is possible to enable or disable messages by selecting them by: - - \list - \li source, type and severity (and including all ids in the selection); - \li id, source and type (and including all severities in the selection). - \endlist - - Note that the "enabled" status for a given message is a property of the - (id, source, type, severity) tuple; the message attributes \e{do not} form - a hierarchy of any kind. You should be careful about the order of the calls - to enableMessages() and disableMessages(), as it will change which - messages will are enabled / disabled. - - It's not possible to filter by the message text itself; applications - have to do that on their own (in slots connected to the messageLogged() - signal, or after fetching the messages in the internal debug log - through loggedMessages()). - - In order to simplify the management of the enabled / disabled statuses, - QOpenGLDebugMessage also supports the concept of \c{debug groups}. A debug - group contains the group of enabled / disabled configurations of debug - messages. Moreover, debug groups are organized in a stack: it is possible - to push and pop groups by calling pushGroup() and popGroup() respectively. - (When an OpenGL context is created, there is already a group in the stack). - - The enableMessages() and disableMessages() functions will modify the - configuration in the current debug group, that is, the one at the top of - the debug groups stack. - - When a new group is pushed onto the debug groups stack, it will inherit - the configuration of the group that was previously on the top of the stack. - Vice versa, popping a debug group will restore the configuration of - the debug group that becomes the new top. - - Pushing (respectively popping) debug groups will also automatically generate - a debug message of type QOpenGLDebugMessage::GroupPushType (respectively - \l{QOpenGLDebugMessage::}{GroupPopType}). - - \sa QOpenGLDebugMessage -*/ - -/*! - \enum QOpenGLDebugMessage::Source - - The Source enum defines the source of the debug message. - - \value InvalidSource - The source of the message is invalid; this is the source of a - default-constructed QOpenGLDebugMessage object. - - \value APISource - The message was generated in response to OpenGL API calls. - - \value WindowSystemSource - The message was generated by the window system. - - \value ShaderCompilerSource - The message was generated by the shader compiler. - - \value ThirdPartySource - The message was generated by a third party, for instance an OpenGL - framework a or debugging toolkit. - - \value ApplicationSource - The message was generated by the application itself. - - \value OtherSource - The message was generated by a source not included in this - enumeration. - - \omitvalue LastSource - - \value AnySource - This value corresponds to a mask of all possible message sources. -*/ - -/*! - \enum QOpenGLDebugMessage::Type - - The Type enum defines the type of the debug message. - - \value InvalidType - The type of the message is invalid; this is the type of a - default-constructed QOpenGLDebugMessage object. - - \value ErrorType - The message represents an error. - - \value DeprecatedBehaviorType - The message represents an usage of deprecated behavior. - - \value UndefinedBehaviorType - The message represents an usage of undefined behavior. - - \value PortabilityType - The message represents an usage of vendor-specific behavior, - that might pose portability concerns. - - \value PerformanceType - The message represents a performance issue. - - \value OtherType - The message represents a type not included in this - enumeration. - - \value MarkerType - The message represents a marker in the debug log. - - \value GroupPushType - The message represents a debug group push operation. - - \value GroupPopType - The message represents a debug group pop operation. - - \omitvalue LastType - - \value AnyType - This value corresponds to a mask of all possible message types. -*/ - -/*! - \enum QOpenGLDebugMessage::Severity - - The Severity enum defines the severity of the debug message. - - \value InvalidSeverity - The severity of the message is invalid; this is the severity of a - default-constructed QOpenGLDebugMessage object. - - \value HighSeverity - The message has a high severity. - - \value MediumSeverity - The message has a medium severity. - - \value LowSeverity - The message has a low severity. - - \value NotificationSeverity - The message is a notification. - - \omitvalue LastSeverity - - \value AnySeverity - This value corresponds to a mask of all possible message severities. -*/ - -/*! - \property QOpenGLDebugLogger::loggingMode - - \brief the logging mode passed to startLogging(). - - Note that logging must have been started or the value of this property - will be meaningless. - - \sa startLogging(), isLogging() -*/ -/*! - \enum QOpenGLDebugLogger::LoggingMode - - The LoggingMode enum defines the logging mode of the logger object. - - \value AsynchronousLogging - Messages from the OpenGL server are logged asynchronously. This means - that messages can be logged some time after the corresponding OpenGL - actions that caused them, and even be received in an out-of-order - fashion, depending on the OpenGL implementation. This mode has a very low - performance penalty, as OpenGL implementations are heavily threaded - and asynchronous by nature. - - \value SynchronousLogging - Messages from the OpenGL server are logged synchronously and - sequentially. This has a severe performance hit, as OpenGL - implementations are very asynchronous by nature; but it's very useful - to debug OpenGL problems, as OpenGL guarantees that the messages - generated by a OpenGL command will be logged before the corresponding - command execution has returned. Therefore, you can install a breakpoint - on the messageLogged() signal and see in the backtrace which OpenGL - command caused it; the only caveat is that if you are using OpenGL from - multiple threads you may need to force direct connection when - connecting to the messageLogged() signal. -*/ - -// When using OpenGL ES 2.0, all the necessary GL_KHR_debug constants are -// provided in qopengles2ext.h. Unfortunately, newer versions of that file -// suffix everything with _KHR which causes extra headache when the goal is -// to have a single piece of code that builds in all our target -// environments. Therefore, try to detect this and use our custom defines -// instead, which we anyway need for OS X. - -#if defined(GL_KHR_debug) && defined(GL_DEBUG_SOURCE_API_KHR) -#define USE_MANUAL_DEFS -#endif - -// Under OSX (at least up to 10.8) we cannot include our copy of glext.h, -// but we use the system-wide one, which unfortunately lacks all the needed -// defines/typedefs. In order to make the code compile, we just add here -// the GL_KHR_debug defines. - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 -#define USE_MANUAL_DEFS -#endif - -#ifdef USE_MANUAL_DEFS - -#ifndef GL_DEBUG_OUTPUT_SYNCHRONOUS -#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#endif -#ifndef GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 -#endif -#ifndef GL_DEBUG_CALLBACK_FUNCTION -#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 -#endif -#ifndef GL_DEBUG_CALLBACK_USER_PARAM -#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 -#endif -#ifndef GL_DEBUG_SOURCE_API -#define GL_DEBUG_SOURCE_API 0x8246 -#endif -#ifndef GL_DEBUG_SOURCE_WINDOW_SYSTEM -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#endif -#ifndef GL_DEBUG_SOURCE_SHADER_COMPILER -#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#endif -#ifndef GL_DEBUG_SOURCE_THIRD_PARTY -#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#endif -#ifndef GL_DEBUG_SOURCE_APPLICATION -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#endif -#ifndef GL_DEBUG_SOURCE_OTHER -#define GL_DEBUG_SOURCE_OTHER 0x824B -#endif -#ifndef GL_DEBUG_TYPE_ERROR -#define GL_DEBUG_TYPE_ERROR 0x824C -#endif -#ifndef GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#endif -#ifndef GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#endif -#ifndef GL_DEBUG_TYPE_PORTABILITY -#define GL_DEBUG_TYPE_PORTABILITY 0x824F -#endif -#ifndef GL_DEBUG_TYPE_PERFORMANCE -#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#endif -#ifndef GL_DEBUG_TYPE_OTHER -#define GL_DEBUG_TYPE_OTHER 0x8251 -#endif -#ifndef GL_DEBUG_TYPE_MARKER -#define GL_DEBUG_TYPE_MARKER 0x8268 -#endif -#ifndef GL_DEBUG_TYPE_PUSH_GROUP -#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 -#endif -#ifndef GL_DEBUG_TYPE_POP_GROUP -#define GL_DEBUG_TYPE_POP_GROUP 0x826A -#endif -#ifndef GL_DEBUG_SEVERITY_NOTIFICATION -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#endif -#ifndef GL_MAX_DEBUG_GROUP_STACK_DEPTH -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C -#endif -#ifndef GL_DEBUG_GROUP_STACK_DEPTH -#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D -#endif -#ifndef GL_BUFFER -#define GL_BUFFER 0x82E0 -#endif -#ifndef GL_SHADER -#define GL_SHADER 0x82E1 -#endif -#ifndef GL_PROGRAM -#define GL_PROGRAM 0x82E2 -#endif -#ifndef GL_QUERY -#define GL_QUERY 0x82E3 -#endif -#ifndef GL_PROGRAM_PIPELINE -#define GL_PROGRAM_PIPELINE 0x82E4 -#endif -#ifndef GL_SAMPLER -#define GL_SAMPLER 0x82E6 -#endif -#ifndef GL_DISPLAY_LIST -#define GL_DISPLAY_LIST 0x82E7 -#endif -#ifndef GL_MAX_LABEL_LENGTH -#define GL_MAX_LABEL_LENGTH 0x82E8 -#endif -#ifndef GL_MAX_DEBUG_MESSAGE_LENGTH -#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 -#endif -#ifndef GL_MAX_DEBUG_LOGGED_MESSAGES -#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 -#endif -#ifndef GL_DEBUG_LOGGED_MESSAGES -#define GL_DEBUG_LOGGED_MESSAGES 0x9145 -#endif -#ifndef GL_DEBUG_SEVERITY_HIGH -#define GL_DEBUG_SEVERITY_HIGH 0x9146 -#endif -#ifndef GL_DEBUG_SEVERITY_MEDIUM -#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#endif -#ifndef GL_DEBUG_SEVERITY_LOW -#define GL_DEBUG_SEVERITY_LOW 0x9148 -#endif -#ifndef GL_DEBUG_OUTPUT -#define GL_DEBUG_OUTPUT 0x92E0 -#endif -#ifndef GL_CONTEXT_FLAG_DEBUG_BIT -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#endif -#ifndef GL_STACK_OVERFLOW -#define GL_STACK_OVERFLOW 0x0503 -#endif -#ifndef GL_STACK_UNDERFLOW -#define GL_STACK_UNDERFLOW 0x0504 -#endif - -typedef void (QOPENGLF_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); - -#endif /* USE_MANUAL_DEFS */ - - -/*! - \internal -*/ -static QOpenGLDebugMessage::Source qt_messageSourceFromGL(GLenum source) -{ - switch (source) { - case GL_DEBUG_SOURCE_API: - return QOpenGLDebugMessage::APISource; - case GL_DEBUG_SOURCE_WINDOW_SYSTEM: - return QOpenGLDebugMessage::WindowSystemSource; - case GL_DEBUG_SOURCE_SHADER_COMPILER: - return QOpenGLDebugMessage::ShaderCompilerSource; - case GL_DEBUG_SOURCE_THIRD_PARTY: - return QOpenGLDebugMessage::ThirdPartySource; - case GL_DEBUG_SOURCE_APPLICATION: - return QOpenGLDebugMessage::ApplicationSource; - case GL_DEBUG_SOURCE_OTHER: - return QOpenGLDebugMessage::OtherSource; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message source from GL"); - return QOpenGLDebugMessage::OtherSource; -} - -/*! - \internal -*/ -static GLenum qt_messageSourceToGL(QOpenGLDebugMessage::Source source) -{ - switch (source) { - case QOpenGLDebugMessage::InvalidSource: - break; - case QOpenGLDebugMessage::APISource: - return GL_DEBUG_SOURCE_API; - case QOpenGLDebugMessage::WindowSystemSource: - return GL_DEBUG_SOURCE_WINDOW_SYSTEM; - case QOpenGLDebugMessage::ShaderCompilerSource: - return GL_DEBUG_SOURCE_SHADER_COMPILER; - case QOpenGLDebugMessage::ThirdPartySource: - return GL_DEBUG_SOURCE_THIRD_PARTY; - case QOpenGLDebugMessage::ApplicationSource: - return GL_DEBUG_SOURCE_APPLICATION; - case QOpenGLDebugMessage::OtherSource: - return GL_DEBUG_SOURCE_OTHER; - case QOpenGLDebugMessage::AnySource: - break; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message source"); - return GL_DEBUG_SOURCE_OTHER; -} - -/*! - \internal -*/ -static QString qt_messageSourceToString(QOpenGLDebugMessage::Source source) -{ - switch (source) { - case QOpenGLDebugMessage::InvalidSource: - return QStringLiteral("InvalidSource"); - case QOpenGLDebugMessage::APISource: - return QStringLiteral("APISource"); - case QOpenGLDebugMessage::WindowSystemSource: - return QStringLiteral("WindowSystemSource"); - case QOpenGLDebugMessage::ShaderCompilerSource: - return QStringLiteral("ShaderCompilerSource"); - case QOpenGLDebugMessage::ThirdPartySource: - return QStringLiteral("ThirdPartySource"); - case QOpenGLDebugMessage::ApplicationSource: - return QStringLiteral("ApplicationSource"); - case QOpenGLDebugMessage::OtherSource: - return QStringLiteral("OtherSource"); - case QOpenGLDebugMessage::AnySource: - return QStringLiteral("AnySource"); - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message source"); - return QString(); -} - -/*! - \internal -*/ -static QOpenGLDebugMessage::Type qt_messageTypeFromGL(GLenum type) -{ - switch (type) { - case GL_DEBUG_TYPE_ERROR: - return QOpenGLDebugMessage::ErrorType; - case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: - return QOpenGLDebugMessage::DeprecatedBehaviorType; - case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: - return QOpenGLDebugMessage::UndefinedBehaviorType; - case GL_DEBUG_TYPE_PORTABILITY: - return QOpenGLDebugMessage::PortabilityType; - case GL_DEBUG_TYPE_PERFORMANCE: - return QOpenGLDebugMessage::PerformanceType; - case GL_DEBUG_TYPE_OTHER: - return QOpenGLDebugMessage::OtherType; - case GL_DEBUG_TYPE_MARKER: - return QOpenGLDebugMessage::MarkerType; - case GL_DEBUG_TYPE_PUSH_GROUP: - return QOpenGLDebugMessage::GroupPushType; - case GL_DEBUG_TYPE_POP_GROUP: - return QOpenGLDebugMessage::GroupPopType; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message type from GL"); - return QOpenGLDebugMessage::OtherType; -} - -/*! - \internal -*/ -static GLenum qt_messageTypeToGL(QOpenGLDebugMessage::Type type) -{ - switch (type) { - case QOpenGLDebugMessage::InvalidType: - break; - case QOpenGLDebugMessage::ErrorType: - return GL_DEBUG_TYPE_ERROR; - case QOpenGLDebugMessage::DeprecatedBehaviorType: - return GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; - case QOpenGLDebugMessage::UndefinedBehaviorType: - return GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; - case QOpenGLDebugMessage::PortabilityType: - return GL_DEBUG_TYPE_PORTABILITY; - case QOpenGLDebugMessage::PerformanceType: - return GL_DEBUG_TYPE_PERFORMANCE; - case QOpenGLDebugMessage::OtherType: - return GL_DEBUG_TYPE_OTHER; - case QOpenGLDebugMessage::MarkerType: - return GL_DEBUG_TYPE_MARKER; - case QOpenGLDebugMessage::GroupPushType: - return GL_DEBUG_TYPE_PUSH_GROUP; - case QOpenGLDebugMessage::GroupPopType: - return GL_DEBUG_TYPE_POP_GROUP; - case QOpenGLDebugMessage::AnyType: - break; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message type"); - return GL_DEBUG_TYPE_OTHER; -} - -/*! - \internal -*/ -static QString qt_messageTypeToString(QOpenGLDebugMessage::Type type) -{ - switch (type) { - case QOpenGLDebugMessage::InvalidType: - return QStringLiteral("InvalidType"); - case QOpenGLDebugMessage::ErrorType: - return QStringLiteral("ErrorType"); - case QOpenGLDebugMessage::DeprecatedBehaviorType: - return QStringLiteral("DeprecatedBehaviorType"); - case QOpenGLDebugMessage::UndefinedBehaviorType: - return QStringLiteral("UndefinedBehaviorType"); - case QOpenGLDebugMessage::PortabilityType: - return QStringLiteral("PortabilityType"); - case QOpenGLDebugMessage::PerformanceType: - return QStringLiteral("PerformanceType"); - case QOpenGLDebugMessage::OtherType: - return QStringLiteral("OtherType"); - case QOpenGLDebugMessage::MarkerType: - return QStringLiteral("MarkerType"); - case QOpenGLDebugMessage::GroupPushType: - return QStringLiteral("GroupPushType"); - case QOpenGLDebugMessage::GroupPopType: - return QStringLiteral("GroupPopType"); - case QOpenGLDebugMessage::AnyType: - return QStringLiteral("AnyType"); - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message type"); - return QString(); -} - -/*! - \internal -*/ -static QOpenGLDebugMessage::Severity qt_messageSeverityFromGL(GLenum severity) -{ - switch (severity) { - case GL_DEBUG_SEVERITY_HIGH: - return QOpenGLDebugMessage::HighSeverity; - case GL_DEBUG_SEVERITY_MEDIUM: - return QOpenGLDebugMessage::MediumSeverity; - case GL_DEBUG_SEVERITY_LOW: - return QOpenGLDebugMessage::LowSeverity; - case GL_DEBUG_SEVERITY_NOTIFICATION: - return QOpenGLDebugMessage::NotificationSeverity; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message severity from GL"); - return QOpenGLDebugMessage::NotificationSeverity; -} - -/*! - \internal -*/ -static GLenum qt_messageSeverityToGL(QOpenGLDebugMessage::Severity severity) -{ - switch (severity) { - case QOpenGLDebugMessage::InvalidSeverity: - break; - case QOpenGLDebugMessage::HighSeverity: - return GL_DEBUG_SEVERITY_HIGH; - case QOpenGLDebugMessage::MediumSeverity: - return GL_DEBUG_SEVERITY_MEDIUM; - case QOpenGLDebugMessage::LowSeverity: - return GL_DEBUG_SEVERITY_LOW; - case QOpenGLDebugMessage::NotificationSeverity: - return GL_DEBUG_SEVERITY_NOTIFICATION; - case QOpenGLDebugMessage::AnySeverity: - break; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message severity"); - return GL_DEBUG_SEVERITY_NOTIFICATION; -} - -/*! - \internal -*/ -static QString qt_messageSeverityToString(QOpenGLDebugMessage::Severity severity) -{ - switch (severity) { - case QOpenGLDebugMessage::InvalidSeverity: - return QStringLiteral("InvalidSeverity"); - case QOpenGLDebugMessage::HighSeverity: - return QStringLiteral("HighSeverity"); - case QOpenGLDebugMessage::MediumSeverity: - return QStringLiteral("MediumSeverity"); - case QOpenGLDebugMessage::LowSeverity: - return QStringLiteral("LowSeverity"); - case QOpenGLDebugMessage::NotificationSeverity: - return QStringLiteral("NotificationSeverity"); - case QOpenGLDebugMessage::AnySeverity: - return QStringLiteral("AnySeverity"); - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message severity"); - return QString(); -} - -class QOpenGLDebugMessagePrivate : public QSharedData -{ -public: - QOpenGLDebugMessagePrivate(); - - QString message; - GLuint id; - QOpenGLDebugMessage::Source source; - QOpenGLDebugMessage::Type type; - QOpenGLDebugMessage::Severity severity; -}; - -/*! - \internal -*/ -QOpenGLDebugMessagePrivate::QOpenGLDebugMessagePrivate() - : message(), - id(0), - source(QOpenGLDebugMessage::InvalidSource), - type(QOpenGLDebugMessage::InvalidType), - severity(QOpenGLDebugMessage::InvalidSeverity) -{ -} - - -/*! - Constructs a debug message with an empty message string, id set to 0, - source set to InvalidSource, type set to InvalidType, and severity set to - InvalidSeverity. - - \note This constructor should not be used to create a debug message; - instead, use the createApplicationMessage() or the createThirdPartyMessage() - static functions. - - \sa createApplicationMessage(), createThirdPartyMessage() -*/ -QOpenGLDebugMessage::QOpenGLDebugMessage() - : d(new QOpenGLDebugMessagePrivate) -{ -} - -/*! - Constructs a debug message as a copy of \a debugMessage. - - \sa operator=() -*/ -QOpenGLDebugMessage::QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage) - : d(debugMessage.d) -{ -} - -/*! - Destroys this debug message. -*/ -QOpenGLDebugMessage::~QOpenGLDebugMessage() -{ -} - -/*! - Assigns the message \a debugMessage to this object, and returns a reference - to the copy. -*/ -QOpenGLDebugMessage &QOpenGLDebugMessage::operator=(const QOpenGLDebugMessage &debugMessage) -{ - d = debugMessage.d; - return *this; -} - -/*! - \fn QOpenGLDebugMessage &QOpenGLDebugMessage::operator=(QOpenGLDebugMessage &&debugMessage) - - Move-assigns \a debugMessage to this object. -*/ - -/*! - \fn void QOpenGLDebugMessage::swap(QOpenGLDebugMessage &debugMessage) - - Swaps the message \a debugMessage with this message. This operation is very - fast and never fails. -*/ - -/*! - Returns the source of the debug message. -*/ -QOpenGLDebugMessage::Source QOpenGLDebugMessage::source() const -{ - return d->source; -} - -/*! - Returns the type of the debug message. -*/ -QOpenGLDebugMessage::Type QOpenGLDebugMessage::type() const -{ - return d->type; -} - -/*! - Returns the severity of the debug message. -*/ -QOpenGLDebugMessage::Severity QOpenGLDebugMessage::severity() const -{ - return d->severity; -} - -/*! - Returns the id of the debug message. Ids are generally vendor-specific. -*/ -GLuint QOpenGLDebugMessage::id() const -{ - return d->id; -} - -/*! - Returns the textual message contained by this debug message. -*/ -QString QOpenGLDebugMessage::message() const -{ - return d->message; -} - -/*! - Constructs and returns a debug message with \a text as its text, \a id - as id, \a severity as severity, and \a type as type. The message source - will be set to ApplicationSource. - - \sa QOpenGLDebugLogger::logMessage(), createThirdPartyMessage() -*/ -QOpenGLDebugMessage QOpenGLDebugMessage::createApplicationMessage(const QString &text, - GLuint id, - QOpenGLDebugMessage::Severity severity, - QOpenGLDebugMessage::Type type) -{ - QOpenGLDebugMessage m; - m.d->message = text; - m.d->id = id; - m.d->severity = severity; - m.d->type = type; - m.d->source = ApplicationSource; - return m; -} - -/*! - Constructs and returns a debug message with \a text as its text, \a id - as id, \a severity as severity, and \a type as type. The message source - will be set to ThirdPartySource. - - \sa QOpenGLDebugLogger::logMessage(), createApplicationMessage() -*/ -QOpenGLDebugMessage QOpenGLDebugMessage::createThirdPartyMessage(const QString &text, - GLuint id, - QOpenGLDebugMessage::Severity severity, - QOpenGLDebugMessage::Type type) -{ - QOpenGLDebugMessage m; - m.d->message = text; - m.d->id = id; - m.d->severity = severity; - m.d->type = type; - m.d->source = ThirdPartySource; - return m; -} - -/*! - Returns \c true if this debug message is equal to \a debugMessage, or false - otherwise. Two debugging messages are equal if they have the same textual - message, the same id, the same source, the same type and the same severity. - - \sa operator!=() -*/ -bool QOpenGLDebugMessage::operator==(const QOpenGLDebugMessage &debugMessage) const -{ - return (d == debugMessage.d) - || (d->id == debugMessage.d->id - && d->source == debugMessage.d->source - && d->type == debugMessage.d->type - && d->severity == debugMessage.d->severity - && d->message == debugMessage.d->message); -} - -/*! - \fn bool QOpenGLDebugMessage::operator!=(const QOpenGLDebugMessage &debugMessage) const - - Returns \c true if this message is different from \a debugMessage, or false - otherwise. - - \sa operator==() -*/ - -#ifndef QT_NO_DEBUG_STREAM -/*! - \relates QOpenGLDebugMessage - - Writes the source \a source into the debug object \a debug for debugging - purposes. -*/ -QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Source source) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QOpenGLDebugMessage::Source(" - << qt_messageSourceToString(source) - << ')'; - return debug; -} - -/*! - \relates QOpenGLDebugMessage - - Writes the type \a type into the debug object \a debug for debugging - purposes. -*/ -QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Type type) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QOpenGLDebugMessage::Type(" - << qt_messageTypeToString(type) - << ')'; - return debug; -} - -/*! - \relates QOpenGLDebugMessage - - Writes the severity \a severity into the debug object \a debug for debugging - purposes. -*/ -QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Severity severity) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QOpenGLDebugMessage::Severity(" - << qt_messageSeverityToString(severity) - << ')'; - return debug; -} - -/*! - \relates QOpenGLDebugMessage - - Writes the message \a message into the debug object \a debug for debugging - purposes. -*/ -QDebug operator<<(QDebug debug, const QOpenGLDebugMessage &message) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QOpenGLDebugMessage(" - << qt_messageSourceToString(message.source()) << ", " - << message.id() << ", " - << message.message() << ", " - << qt_messageSeverityToString(message.severity()) << ", " - << qt_messageTypeToString(message.type()) << ')'; - return debug; - -} -#endif // QT_NO_DEBUG_STREAM - -typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageControl_t)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageInsert_t)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageCallback_t)(GLDEBUGPROC callback, const void *userParam); -typedef GLuint (QOPENGLF_APIENTRYP qt_glGetDebugMessageLog_t)(GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -typedef void (QOPENGLF_APIENTRYP qt_glPushDebugGroup_t)(GLenum source, GLuint id, GLsizei length, const GLchar *message); -typedef void (QOPENGLF_APIENTRYP qt_glPopDebugGroup_t)(); -typedef void (QOPENGLF_APIENTRYP qt_glGetPointerv_t)(GLenum pname, GLvoid **params); - -class QOpenGLDebugLoggerPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QOpenGLDebugLogger) -public: - QOpenGLDebugLoggerPrivate(); - - void handleMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *rawMessage); - void controlDebugMessages(QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities, - const QVector &ids, - const QByteArray &callerName, - bool enable); - void _q_contextAboutToBeDestroyed(); - - qt_glDebugMessageControl_t glDebugMessageControl; - qt_glDebugMessageInsert_t glDebugMessageInsert; - qt_glDebugMessageCallback_t glDebugMessageCallback; - qt_glGetDebugMessageLog_t glGetDebugMessageLog; - qt_glPushDebugGroup_t glPushDebugGroup; - qt_glPopDebugGroup_t glPopDebugGroup; - qt_glGetPointerv_t glGetPointerv; - - GLDEBUGPROC oldDebugCallbackFunction; - void *oldDebugCallbackParameter; - QOpenGLContext *context; - GLint maxMessageLength; - QOpenGLDebugLogger::LoggingMode loggingMode; - bool initialized : 1; - bool isLogging : 1; - bool debugWasEnabled : 1; - bool syncDebugWasEnabled : 1; -}; - -/*! - \internal -*/ -QOpenGLDebugLoggerPrivate::QOpenGLDebugLoggerPrivate() - : glDebugMessageControl(nullptr), - glDebugMessageInsert(nullptr), - glDebugMessageCallback(nullptr), - glGetDebugMessageLog(nullptr), - glPushDebugGroup(nullptr), - glPopDebugGroup(nullptr), - oldDebugCallbackFunction(nullptr), - context(nullptr), - maxMessageLength(0), - loggingMode(QOpenGLDebugLogger::AsynchronousLogging), - initialized(false), - isLogging(false), - debugWasEnabled(false), - syncDebugWasEnabled(false) -{ -} - -/*! - \internal -*/ -void QOpenGLDebugLoggerPrivate::handleMessage(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar *rawMessage) -{ - if (oldDebugCallbackFunction) - oldDebugCallbackFunction(source, type, id, severity, length, rawMessage, oldDebugCallbackParameter); - - QOpenGLDebugMessage message; - - QOpenGLDebugMessagePrivate *messagePrivate = message.d.data(); - messagePrivate->source = qt_messageSourceFromGL(source); - messagePrivate->type = qt_messageTypeFromGL(type); - messagePrivate->id = id; - messagePrivate->severity = qt_messageSeverityFromGL(severity); - // not passing the length to fromUtf8, as some bugged OpenGL drivers - // do not handle the length correctly. Just rely on the message to be NUL terminated. - messagePrivate->message = QString::fromUtf8(rawMessage); - - Q_Q(QOpenGLDebugLogger); - emit q->messageLogged(message); -} - -/*! - \internal -*/ -void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities, - const QVector &ids, - const QByteArray &callerName, - bool enable) -{ - if (!initialized) { - qWarning("QOpenGLDebugLogger::%s(): object must be initialized before enabling/disabling messages", callerName.constData()); - return; - } - if (sources == QOpenGLDebugMessage::InvalidSource) { - qWarning("QOpenGLDebugLogger::%s(): invalid source specified", callerName.constData()); - return; - } - if (types == QOpenGLDebugMessage::InvalidType) { - qWarning("QOpenGLDebugLogger::%s(): invalid type specified", callerName.constData()); - return; - } - if (severities == QOpenGLDebugMessage::InvalidSeverity) { - qWarning("QOpenGLDebugLogger::%s(): invalid severity specified", callerName.constData()); - return; - } - - QVarLengthArray glSources; - QVarLengthArray glTypes; - QVarLengthArray glSeverities; - - if (ids.count() > 0) { - Q_ASSERT(severities == QOpenGLDebugMessage::AnySeverity); - - // The GL_KHR_debug extension says: - // - // - If is greater than zero, then is an array of - // message IDs for the specified combination of and . In - // this case, if or is DONT_CARE, or is not - // DONT_CARE, the error INVALID_OPERATION is generated. If is - // zero, the value if is ignored. - // - // This means we can't convert AnySource or AnyType into DONT_CARE, but we have to roll - // them into individual sources/types. - - if (sources == QOpenGLDebugMessage::AnySource) { - sources = QOpenGLDebugMessage::InvalidSource; - for (uint i = 1; i <= QOpenGLDebugMessage::LastSource; i = i << 1) - sources |= QOpenGLDebugMessage::Source(i); - } - - if (types == QOpenGLDebugMessage::AnyType) { - types = QOpenGLDebugMessage::InvalidType; - for (uint i = 1; i <= QOpenGLDebugMessage::LastType; i = i << 1) - types |= QOpenGLDebugMessage::Type(i); - } - } - -#define CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(type, source, target) \ - if (source == QOpenGLDebugMessage::Any ## type) { \ - target << GL_DONT_CARE; \ - } else { \ - for (uint i = 1; i <= QOpenGLDebugMessage::Last ## type; i = i << 1) \ - if (source.testFlag(QOpenGLDebugMessage:: type (i))) \ - target << qt_message ## type ## ToGL (QOpenGLDebugMessage:: type (i)); \ - } - - CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Source, sources, glSources) - CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Type, types, glTypes) - CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Severity, severities, glSeverities) -#undef CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS - - const GLsizei idCount = ids.count(); - // The GL_KHR_debug extension says that if idCount is 0, idPtr must be ignored. - // Unfortunately, some bugged drivers do NOT ignore it, so pass NULL in case. - const GLuint * const idPtr = idCount ? ids.constData() : nullptr; - - for (GLenum source : glSources) - for (GLenum type : glTypes) - for (GLenum severity : glSeverities) - glDebugMessageControl(source, type, severity, idCount, idPtr, GLboolean(enable)); -} - -/*! - \internal -*/ -void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed() -{ - Q_ASSERT(context); - - // Re-make our context current somehow, otherwise stopLogging will fail. - - // Save the current context and its surface in case we need to set them back - QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - QSurface *currentSurface = nullptr; - - QScopedPointer offscreenSurface; - - if (context != currentContext) { - // Make our old context current on a temporary surface - if (currentContext) - currentSurface = currentContext->surface(); - - offscreenSurface.reset(new QOffscreenSurface); - offscreenSurface->setFormat(context->format()); - offscreenSurface->create(); - if (!context->makeCurrent(offscreenSurface.data())) - qWarning("QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed(): could not make the owning GL context current for cleanup"); - } - - Q_Q(QOpenGLDebugLogger); - q->stopLogging(); - - if (offscreenSurface) { - // We did change the current context: set it back - if (currentContext) - currentContext->makeCurrent(currentSurface); - else - context->doneCurrent(); - } - - QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); - context = nullptr; - initialized = false; -} - -extern "C" { -static void QOPENGLF_APIENTRY qt_opengl_debug_callback(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar *rawMessage, - const GLvoid *userParam) -{ - QOpenGLDebugLoggerPrivate *loggerPrivate = static_cast(const_cast(userParam)); - loggerPrivate->handleMessage(source, type, id, severity, length, rawMessage); -} -} - -/*! - Constructs a new logger object with the given \a parent. - - \note The object must be initialized before logging can happen. - - \sa initialize() -*/ -QOpenGLDebugLogger::QOpenGLDebugLogger(QObject *parent) - : QObject(*new QOpenGLDebugLoggerPrivate, parent) -{ - // QOpenGLDebugMessage is going to be mostly used as an argument - // of a cross thread connection, therefore let's ease the life for the users - // and register the type for them. - qRegisterMetaType(); -} - -/*! - Destroys the logger object. -*/ -QOpenGLDebugLogger::~QOpenGLDebugLogger() -{ - stopLogging(); -} - -/*! - Initializes the object in the current OpenGL context. The context must - support the \c{GL_KHR_debug} extension for the initialization to succeed. - The object must be initialized before any logging can happen. - - It is safe to call this function multiple times from the same context. - - This function can also be used to change the context of a previously - initialized object; note that in this case the object must not be logging - when you call this function. - - Returns \c true if the logger is successfully initialized; false otherwise. - - \sa QOpenGLContext -*/ -bool QOpenGLDebugLogger::initialize() -{ - QOpenGLContext *context = QOpenGLContext::currentContext(); - if (!context) { - qWarning("QOpenGLDebugLogger::initialize(): no current OpenGL context found."); - return false; - } - - Q_D(QOpenGLDebugLogger); - if (d->context == context) { - // context is non-NULL, d->context is non NULL only on successful initialization. - Q_ASSERT(d->initialized); - return true; - } - - if (d->isLogging) { - qWarning("QOpenGLDebugLogger::initialize(): cannot initialize the object while logging. Please stop the logging first."); - return false; - } - - if (d->context) - disconnect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed())); - - d->initialized = false; - d->context = nullptr; - - if (!context->hasExtension(QByteArrayLiteral("GL_KHR_debug"))) - return false; - - d->context = context; - connect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed())); - -#define GET_DEBUG_PROC_ADDRESS(procName) \ - d->procName = reinterpret_cast< qt_ ## procName ## _t >( \ - d->context->getProcAddress(d->context->isOpenGLES() ? (#procName "KHR") : (#procName)) \ - ); - - GET_DEBUG_PROC_ADDRESS(glDebugMessageControl); - GET_DEBUG_PROC_ADDRESS(glDebugMessageInsert); - GET_DEBUG_PROC_ADDRESS(glDebugMessageCallback); - GET_DEBUG_PROC_ADDRESS(glGetDebugMessageLog); - GET_DEBUG_PROC_ADDRESS(glPushDebugGroup); - GET_DEBUG_PROC_ADDRESS(glPopDebugGroup); - GET_DEBUG_PROC_ADDRESS(glGetPointerv) - -#undef GET_DEBUG_PROC_ADDRESS - - QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &d->maxMessageLength); - -#ifndef QT_NO_DEBUG - if (!d->context->format().testOption(QSurfaceFormat::DebugContext)) { - qWarning("QOpenGLDebugLogger::initialize(): the current context is not a debug context:\n" - " this means that the GL may not generate any debug output at all.\n" - " To avoid this warning, try creating the context with the\n" - " QSurfaceFormat::DebugContext surface format option."); - } -#endif // QT_NO_DEBUG - - d->initialized = true; - return true; -} - -/*! - Returns \c true if this object is currently logging, false otherwise. - - \sa startLogging() -*/ -bool QOpenGLDebugLogger::isLogging() const -{ - Q_D(const QOpenGLDebugLogger); - return d->isLogging; -} - -/*! - Starts logging messages coming from the OpenGL server. When a new message - is received, the signal messageLogged() is emitted, carrying the logged - message as argument. - - \a loggingMode specifies whether the logging must be asynchronous (the default) - or synchronous. - - QOpenGLDebugLogger will record the values of \c{GL_DEBUG_OUTPUT} and - \c{GL_DEBUG_OUTPUT_SYNCHRONOUS} when logging is started, and set them back - when logging is stopped. Moreover, any user-defined OpenGL debug callback - installed when this function is invoked will be restored when logging is - stopped; QOpenGLDebugLogger will ensure that the pre-existing callback will - still be invoked when logging. - - \note It's not possible to change the logging mode without stopping and - starting logging again. This might change in a future version of Qt. - - \note The object must be initialized before logging can happen. - - \sa stopLogging(), initialize() -*/ -void QOpenGLDebugLogger::startLogging(QOpenGLDebugLogger::LoggingMode loggingMode) -{ - Q_D(QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::startLogging(): object must be initialized before logging can start"); - return; - } - if (d->isLogging) { - qWarning("QOpenGLDebugLogger::startLogging(): this object is already logging"); - return; - } - - d->isLogging = true; - d->loggingMode = loggingMode; - - d->glGetPointerv(GL_DEBUG_CALLBACK_FUNCTION, reinterpret_cast(&d->oldDebugCallbackFunction)); - d->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM, &d->oldDebugCallbackParameter); - - d->glDebugMessageCallback(&qt_opengl_debug_callback, d); - - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - d->debugWasEnabled = funcs->glIsEnabled(GL_DEBUG_OUTPUT); - d->syncDebugWasEnabled = funcs->glIsEnabled(GL_DEBUG_OUTPUT_SYNCHRONOUS); - - if (d->loggingMode == SynchronousLogging) - funcs->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - else - funcs->glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - - funcs->glEnable(GL_DEBUG_OUTPUT); -} - -/*! - Returns the logging mode of the object. - - \sa startLogging() -*/ -QOpenGLDebugLogger::LoggingMode QOpenGLDebugLogger::loggingMode() const -{ - Q_D(const QOpenGLDebugLogger); - return d->loggingMode; -} - -/*! - Stops logging messages from the OpenGL server. - - \sa startLogging() -*/ -void QOpenGLDebugLogger::stopLogging() -{ - Q_D(QOpenGLDebugLogger); - if (!d->isLogging) - return; - - QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - if (!currentContext || currentContext != d->context) { - qWarning("QOpenGLDebugLogger::stopLogging(): attempting to stop logging with the wrong OpenGL context current"); - return; - } - - d->isLogging = false; - - d->glDebugMessageCallback(d->oldDebugCallbackFunction, d->oldDebugCallbackParameter); - - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - if (!d->debugWasEnabled) - funcs->glDisable(GL_DEBUG_OUTPUT); - - if (d->syncDebugWasEnabled) - funcs->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - else - funcs->glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); -} - -/*! - Inserts the message \a debugMessage into the OpenGL debug log. This provides - a way for applications or libraries to insert custom messages that can - ease the debugging of OpenGL applications. - - \note \a debugMessage must have QOpenGLDebugMessage::ApplicationSource or - QOpenGLDebugMessage::ThirdPartySource as its source, and a valid - type and severity, otherwise it will not be inserted into the log. - - \note The object must be initialized before logging can happen. - - \sa initialize() -*/ -void QOpenGLDebugLogger::logMessage(const QOpenGLDebugMessage &debugMessage) -{ - Q_D(QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::logMessage(): object must be initialized before logging messages"); - return; - } - if (debugMessage.source() != QOpenGLDebugMessage::ApplicationSource - && debugMessage.source() != QOpenGLDebugMessage::ThirdPartySource) { - qWarning("QOpenGLDebugLogger::logMessage(): using a message source different from ApplicationSource\n" - " or ThirdPartySource is not supported by GL_KHR_debug. The message will not be logged."); - return; - } - if (debugMessage.type() == QOpenGLDebugMessage::InvalidType - || debugMessage.type() == QOpenGLDebugMessage::AnyType - || debugMessage.severity() == QOpenGLDebugMessage::InvalidSeverity - || debugMessage.severity() == QOpenGLDebugMessage::AnySeverity) { - qWarning("QOpenGLDebugLogger::logMessage(): the message has a non-valid type and/or severity. The message will not be logged."); - return; - } - - const GLenum source = qt_messageSourceToGL(debugMessage.source()); - const GLenum type = qt_messageTypeToGL(debugMessage.type()); - const GLenum severity = qt_messageSeverityToGL(debugMessage.severity()); - QByteArray rawMessage = debugMessage.message().toUtf8(); - rawMessage.append('\0'); - - if (rawMessage.length() > d->maxMessageLength) { - qWarning("QOpenGLDebugLogger::logMessage(): message too long, truncating it\n" - " (%d bytes long, but the GL accepts up to %d bytes)", rawMessage.length(), d->maxMessageLength); - rawMessage.resize(d->maxMessageLength - 1); - rawMessage.append('\0'); - } - - // Don't pass rawMessage.length(), as unfortunately bugged - // OpenGL drivers will eat the trailing NUL in the message. Just rely - // on the message being NUL terminated. - d->glDebugMessageInsert(source, - type, - debugMessage.id(), - severity, - -1, - rawMessage.constData()); -} - -/*! - Pushes a debug group with name \a name, id \a id, and source \a source onto - the debug groups stack. If the group is successfully pushed, OpenGL will - automatically log a message with message \a name, id \a id, source \a - source, type QOpenGLDebugMessage::GroupPushType and severity - QOpenGLDebugMessage::NotificationSeverity. - - The newly pushed group will inherit the same filtering settings of the - group that was on the top of the stack; that is, the filtering will not be - changed by pushing a new group. - - \note The \a source must either be QOpenGLDebugMessage::ApplicationSource or - QOpenGLDebugMessage::ThirdPartySource, otherwise the group will not be pushed. - - \note The object must be initialized before managing debug groups. - - \sa popGroup(), enableMessages(), disableMessages() -*/ -void QOpenGLDebugLogger::pushGroup(const QString &name, GLuint id, QOpenGLDebugMessage::Source source) -{ - Q_D(QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::pushGroup(): object must be initialized before pushing a debug group"); - return; - } - if (source != QOpenGLDebugMessage::ApplicationSource - && source != QOpenGLDebugMessage::ThirdPartySource) { - qWarning("QOpenGLDebugLogger::pushGroup(): using a source different from ApplicationSource\n" - " or ThirdPartySource is not supported by GL_KHR_debug. The group will not be pushed."); - return; - } - - QByteArray rawName = name.toUtf8(); - rawName.append('\0'); - if (rawName.length() > d->maxMessageLength) { - qWarning("QOpenGLDebugLogger::pushGroup(): group name too long, truncating it\n" - " (%d bytes long, but the GL accepts up to %d bytes)", rawName.length(), d->maxMessageLength); - rawName.resize(d->maxMessageLength - 1); - rawName.append('\0'); - } - - // Don't pass rawMessage.length(), as unfortunately bugged - // OpenGL drivers will eat the trailing NUL in the name. Just rely - // on the name being NUL terminated. - d->glPushDebugGroup(qt_messageSourceToGL(source), id, -1, rawName.constData()); -} - -/*! - Pops the topmost debug group from the debug groups stack. If the group is - successfully popped, OpenGL will automatically log a message with message, - id and source matching those of the popped group, type - QOpenGLDebugMessage::GroupPopType and severity - QOpenGLDebugMessage::NotificationSeverity. - - Popping a debug group will restore the message filtering settings of the - group that becomes the top of the debug groups stack. - - \note The object must be initialized before managing debug groups. - - \sa pushGroup() -*/ -void QOpenGLDebugLogger::popGroup() -{ - Q_D(QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::pushGroup(): object must be initialized before popping a debug group"); - return; - } - - d->glPopDebugGroup(); -} - -/*! - Enables the logging of messages from the given \a sources, of the given \a - types and with the given \a severities and any message id. - - The logging will be enabled in the current control group. - - \sa disableMessages(), pushGroup(), popGroup() -*/ -void QOpenGLDebugLogger::enableMessages(QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities) -{ - Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - severities, - QVector(), - QByteArrayLiteral("enableMessages"), - true); -} - -/*! - Enables the logging of messages with the given \a ids, from the given \a - sources and of the given \a types and any severity. - - The logging will be enabled in the current control group. - - \sa disableMessages(), pushGroup(), popGroup() -*/ -void QOpenGLDebugLogger::enableMessages(const QVector &ids, - QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types) -{ - Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - QOpenGLDebugMessage::AnySeverity, - ids, - QByteArrayLiteral("enableMessages"), - true); -} - -/*! - Disables the logging of messages with the given \a sources, of the given \a - types and with the given \a severities and any message id. - - The logging will be disabled in the current control group. - - \sa enableMessages(), pushGroup(), popGroup() -*/ -void QOpenGLDebugLogger::disableMessages(QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities) -{ - Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - severities, - QVector(), - QByteArrayLiteral("disableMessages"), - false); -} - -/*! - Disables the logging of messages with the given \a ids, from the given \a - sources and of the given \a types and any severity. - - The logging will be disabled in the current control group. - - \sa enableMessages(), pushGroup(), popGroup() -*/ -void QOpenGLDebugLogger::disableMessages(const QVector &ids, - QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types) -{ - Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - QOpenGLDebugMessage::AnySeverity, - ids, - QByteArrayLiteral("disableMessages"), - false); -} - -/*! - Reads all the available messages in the OpenGL internal debug log and - returns them. Moreover, this function will clear the internal debug log, - so that subsequent invocations will not return messages that were - already returned. - - \sa startLogging() -*/ -QList QOpenGLDebugLogger::loggedMessages() const -{ - Q_D(const QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::loggedMessages(): object must be initialized before reading logged messages"); - return QList(); - } - - static const GLuint maxMessageCount = 128; - GLuint messagesRead; - GLenum messageSources[maxMessageCount]; - GLenum messageTypes[maxMessageCount]; - GLuint messageIds[maxMessageCount]; - GLenum messageSeverities[maxMessageCount]; - GLsizei messageLengths[maxMessageCount]; - - QByteArray messagesBuffer; - messagesBuffer.resize(maxMessageCount * d->maxMessageLength); - - QList messages; - do { - messagesRead = d->glGetDebugMessageLog(maxMessageCount, - GLsizei(messagesBuffer.size()), - messageSources, - messageTypes, - messageIds, - messageSeverities, - messageLengths, - messagesBuffer.data()); - - const char *messagesBufferPtr = messagesBuffer.constData(); - for (GLuint i = 0; i < messagesRead; ++i) { - QOpenGLDebugMessage message; - - QOpenGLDebugMessagePrivate *messagePrivate = message.d.data(); - messagePrivate->source = qt_messageSourceFromGL(messageSources[i]); - messagePrivate->type = qt_messageTypeFromGL(messageTypes[i]); - messagePrivate->id = messageIds[i]; - messagePrivate->severity = qt_messageSeverityFromGL(messageSeverities[i]); - messagePrivate->message = QString::fromUtf8(messagesBufferPtr, messageLengths[i] - 1); - - messagesBufferPtr += messageLengths[i]; - messages << message; - } - } while (messagesRead == maxMessageCount); - - return messages; -} - -/*! - \fn void QOpenGLDebugLogger::messageLogged(const QOpenGLDebugMessage &debugMessage) - - This signal is emitted when a debug message (wrapped by the \a debugMessage - argument) is logged from the OpenGL server. - - Depending on the OpenGL implementation, this signal can be emitted - from other threads than the one(s) the receiver(s) lives in, and even - different from the thread the QOpenGLContext in which this object has - been initialized lives in. Moreover, the signal could be emitted from - multiple threads at the same time. This is normally not a problem, - as Qt will utilize a queued connection for cross-thread signal emissions, - but if you force the connection type to Direct then you must be aware of - the potential races in the slots connected to this signal. - - If logging have been started in SynchronousLogging mode, OpenGL guarantees - that this signal will be emitted from the same thread the QOpenGLContext - has been bound to, and no concurrent invocations will ever happen. - - \note Logging must have been started, or this signal will not be emitted. - - \sa startLogging() -*/ - -/*! - Returns the maximum supported length, in bytes, for the text of the messages - passed to logMessage(). This is also the maximum length of a debug group - name, as pushing or popping groups will automatically log a message with - the debug group name as the message text. - - If a message text is too long, it will be automatically truncated by - QOpenGLDebugLogger. - - \note Message texts are encoded in UTF-8 when they get passed to OpenGL, so - their size in bytes does not usually match the amount of UTF-16 code units, - as returned, for instance, by QString::length(). (It does if the message contains - 7-bit ASCII only data, which is typical for debug messages.) -*/ -qint64 QOpenGLDebugLogger::maximumMessageLength() const -{ - Q_D(const QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::maximumMessageLength(): object must be initialized before reading the maximum message length"); - return -1; - } - return d->maxMessageLength; -} - - -QT_END_NAMESPACE - -#include "moc_qopengldebug.cpp" diff --git a/src/gui/opengl/qopengldebug.h b/src/gui/opengl/qopengldebug.h deleted file mode 100644 index 7363985d60..0000000000 --- a/src/gui/opengl/qopengldebug.h +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLDEBUG_H -#define QOPENGLDEBUG_H - -#include - -#ifndef QT_NO_OPENGL - -#include -#include -#include -#include -#include -#include -#include - -#if defined(Q_CLANG_QDOC) -#undef GLuint -typedef unsigned int GLuint; -#endif - -QT_BEGIN_NAMESPACE - -class QOpenGLDebugLogger; -class QOpenGLDebugLoggerPrivate; -class QOpenGLDebugMessagePrivate; - -class Q_GUI_EXPORT QOpenGLDebugMessage -{ -public: - enum Source { - InvalidSource = 0x00000000, - APISource = 0x00000001, - WindowSystemSource = 0x00000002, - ShaderCompilerSource = 0x00000004, - ThirdPartySource = 0x00000008, - ApplicationSource = 0x00000010, - OtherSource = 0x00000020, - LastSource = OtherSource, // private API - AnySource = 0xffffffff - }; - Q_DECLARE_FLAGS(Sources, Source) - - enum Type { - InvalidType = 0x00000000, - ErrorType = 0x00000001, - DeprecatedBehaviorType = 0x00000002, - UndefinedBehaviorType = 0x00000004, - PortabilityType = 0x00000008, - PerformanceType = 0x00000010, - OtherType = 0x00000020, - MarkerType = 0x00000040, - GroupPushType = 0x00000080, - GroupPopType = 0x00000100, - LastType = GroupPopType, // private API - AnyType = 0xffffffff - }; - Q_DECLARE_FLAGS(Types, Type) - - enum Severity { - InvalidSeverity = 0x00000000, - HighSeverity = 0x00000001, - MediumSeverity = 0x00000002, - LowSeverity = 0x00000004, - NotificationSeverity = 0x00000008, - LastSeverity = NotificationSeverity, // private API - AnySeverity = 0xffffffff - }; - Q_DECLARE_FLAGS(Severities, Severity) - - QOpenGLDebugMessage(); - QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage); - - QOpenGLDebugMessage &operator=(const QOpenGLDebugMessage &debugMessage); - QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&other) noexcept { swap(other); return *this; } - ~QOpenGLDebugMessage(); - - void swap(QOpenGLDebugMessage &other) noexcept { qSwap(d, other.d); } - - Source source() const; - Type type() const; - Severity severity() const; - GLuint id() const; - QString message() const; - - static QOpenGLDebugMessage createApplicationMessage(const QString &text, - GLuint id = 0, - Severity severity = NotificationSeverity, - Type type = OtherType); - static QOpenGLDebugMessage createThirdPartyMessage(const QString &text, - GLuint id = 0, - Severity severity = NotificationSeverity, - Type type = OtherType); - - bool operator==(const QOpenGLDebugMessage &debugMessage) const; - inline bool operator!=(const QOpenGLDebugMessage &debugMessage) const { return !operator==(debugMessage); } - -private: - friend class QOpenGLDebugLogger; - friend class QOpenGLDebugLoggerPrivate; - QSharedDataPointer d; -}; - -Q_DECLARE_SHARED(QOpenGLDebugMessage) -Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Sources) -Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Types) -Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Severities) - -#ifndef QT_NO_DEBUG_STREAM -Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLDebugMessage &message); -Q_GUI_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Source source); -Q_GUI_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Type type); -Q_GUI_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Severity severity); -#endif - -class QOpenGLDebugLoggerPrivate; - -class Q_GUI_EXPORT QOpenGLDebugLogger : public QObject -{ - Q_OBJECT - Q_PROPERTY(LoggingMode loggingMode READ loggingMode) - -public: - enum LoggingMode { - AsynchronousLogging, - SynchronousLogging - }; - Q_ENUM(LoggingMode) - - explicit QOpenGLDebugLogger(QObject *parent = nullptr); - ~QOpenGLDebugLogger(); - - bool initialize(); - - bool isLogging() const; - LoggingMode loggingMode() const; - - qint64 maximumMessageLength() const; - - void pushGroup(const QString &name, - GLuint id = 0, - QOpenGLDebugMessage::Source source = QOpenGLDebugMessage::ApplicationSource); - void popGroup(); - - void enableMessages(QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, - QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType, - QOpenGLDebugMessage::Severities severities = QOpenGLDebugMessage::AnySeverity); - - void enableMessages(const QVector &ids, - QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, - QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType); - - void disableMessages(QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, - QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType, - QOpenGLDebugMessage::Severities severities = QOpenGLDebugMessage::AnySeverity); - - void disableMessages(const QVector &ids, - QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, - QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType); - - QList loggedMessages() const; - -public Q_SLOTS: - void logMessage(const QOpenGLDebugMessage &debugMessage); - void startLogging(LoggingMode loggingMode = AsynchronousLogging); - void stopLogging(); - -Q_SIGNALS: - void messageLogged(const QOpenGLDebugMessage &debugMessage); - -private: - Q_DISABLE_COPY(QOpenGLDebugLogger) - Q_DECLARE_PRIVATE(QOpenGLDebugLogger) - Q_PRIVATE_SLOT(d_func(), void _q_contextAboutToBeDestroyed()) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QOpenGLDebugMessage) - -#endif // QT_NO_OPENGL - -#endif // QOPENGLDEBUG_H -- cgit v1.2.3 From 5a660353edde7b9f382ee41ecf278fc4537f38fa Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 13 Nov 2019 10:20:09 +0100 Subject: Doc: Fix qdoc compilation errors qtbase Task-number: QTBUG-79824 Change-Id: I6557de598de1931fc30556951d35783d02b83abe Reviewed-by: Paul Wicking --- src/gui/doc/src/qtgui.qdoc | 2 +- src/gui/kernel/qwindow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc index c4e7d32de1..392b6040cb 100644 --- a/src/gui/doc/src/qtgui.qdoc +++ b/src/gui/doc/src/qtgui.qdoc @@ -62,7 +62,7 @@ \include module-use.qdocinc using qt module \quotefile overview/using-qt-gui.cmake - See also the \l[QtDoc]{Building with CMake} overview. + See also the \l[QtDoc]{Build with CMake} overview. \section2 Building with qmake diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b71a0c54aa..f701755500 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1344,7 +1344,7 @@ Qt::WindowStates QWindow::windowStates() const This is a hint to the window manager that this window is a dialog or pop-up on behalf of the transient parent. - In order to cause the window to be centered above its transient parent by + In order to cause the window to be centered above its transient \a parent by default, depending on the window manager, it may also be necessary to call setFlags() with a suitable \l Qt::WindowType (such as \c Qt::Dialog). -- cgit v1.2.3 From 4639660dedceba7c16e1a8110bba16eff30be312 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Dec 2019 13:27:49 +0100 Subject: rhi: metal: Skip inactive resources The Quick3D-on-RHI PoC demonstrates a case which the Metal backend fails to handle correctly: have an object with a lighting-enabled material, but remove all lights from the scene. Under the hood this means having a uniform block in the shader, but without referencing it in any way in the actual shader code. This leads to the resource being present (as far as shader reflection is concerned), but with no native binding point available, meaning the attempt to retrieve the Metal binding point for it returns -1, and that is what the QShader carries in the nativeResourceBindingMap. The backend should be prepared to silently skip the resource, whereas currently we end up in an assertion due to attempting to batch the (native) binding "-1", which is invalid. Correct this. Change-Id: I85ee58145f589aca45d46c23e0cdce837d598850 Fixes: QTBUG-80668 Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhimetal.mm | 104 +++++++++++++++++++++++++++++++++-------------- src/gui/rhi/qshader.cpp | 7 ++++ 2 files changed, 81 insertions(+), 30 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 3aa68db585..b6ca40e08b 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -673,12 +673,17 @@ static inline int mapBinding(int binding, BindingType type) { const QShader::NativeResourceBindingMap *map = nativeResourceBindingMaps[stageIndex]; - if (map) { - auto it = map->constFind(binding); - if (it != map->cend()) - return type == BindingType::Sampler ? it->second : it->first; - } - return binding; + if (!map) + return binding; // old QShader versions do not have this map, assume 1:1 mapping then + + auto it = map->constFind(binding); + if (it != map->cend()) + return type == BindingType::Sampler ? it->second : it->first; // may be -1, if the resource is inactive + + // Hitting this path is normal too, is not given that the resource (e.g. a + // uniform block) is really present in the shaders for all the stages + // specified by the visibility mask in the QRhiShaderResourceBinding. + return -1; } void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD, @@ -712,16 +717,25 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD } } if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { - res[VERTEX].buffers.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[VERTEX].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[VERTEX].buffers.feed(nativeBinding, mtlbuf); + res[VERTEX].bufferOffsets.feed(b->binding, offset); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { - res[FRAGMENT].buffers.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[FRAGMENT].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[FRAGMENT].buffers.feed(nativeBinding, mtlbuf); + res[FRAGMENT].bufferOffsets.feed(b->binding, offset); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { - res[COMPUTE].buffers.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[COMPUTE].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[COMPUTE].buffers.feed(nativeBinding, mtlbuf); + res[COMPUTE].bufferOffsets.feed(b->binding, offset); + } } } break; @@ -730,16 +744,28 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.stex.tex); QMetalSampler *samplerD = QRHI_RES(QMetalSampler, b->u.stex.sampler); if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { - res[VERTEX].textures.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture), texD->d->tex); - res[VERTEX].samplers.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Sampler), samplerD->d->samplerState); + const int nativeBindingTexture = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[VERTEX].textures.feed(nativeBindingTexture, texD->d->tex); + res[VERTEX].samplers.feed(nativeBindingSampler, samplerD->d->samplerState); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { - res[FRAGMENT].textures.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture), texD->d->tex); - res[FRAGMENT].samplers.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Sampler), samplerD->d->samplerState); + const int nativeBindingTexture = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[FRAGMENT].textures.feed(nativeBindingTexture, texD->d->tex); + res[FRAGMENT].samplers.feed(nativeBindingSampler, samplerD->d->samplerState); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { - res[COMPUTE].textures.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture), texD->d->tex); - res[COMPUTE].samplers.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Sampler), samplerD->d->samplerState); + const int nativeBindingTexture = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[COMPUTE].textures.feed(nativeBindingTexture, texD->d->tex); + res[COMPUTE].samplers.feed(nativeBindingSampler, samplerD->d->samplerState); + } } } break; @@ -751,12 +777,21 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); id t = texD->d->viewForLevel(b->u.simage.level); - if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) - res[VERTEX].textures.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture), t); - if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) - res[FRAGMENT].textures.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture), t); - if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) - res[COMPUTE].textures.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture), t); + if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { + const int nativeBinding = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture); + if (nativeBinding >= 0) + res[VERTEX].textures.feed(nativeBinding, t); + } + if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { + const int nativeBinding = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture); + if (nativeBinding >= 0) + res[FRAGMENT].textures.feed(nativeBinding, t); + } + if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { + const int nativeBinding = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture); + if (nativeBinding >= 0) + res[COMPUTE].textures.feed(nativeBinding, t); + } } break; case QRhiShaderResourceBinding::BufferLoad: @@ -769,16 +804,25 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD id mtlbuf = bufD->d->buf[0]; uint offset = uint(b->u.sbuf.offset); if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { - res[VERTEX].buffers.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[VERTEX].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[VERTEX].buffers.feed(nativeBinding, mtlbuf); + res[VERTEX].bufferOffsets.feed(b->binding, offset); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { - res[FRAGMENT].buffers.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[FRAGMENT].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[FRAGMENT].buffers.feed(nativeBinding, mtlbuf); + res[FRAGMENT].bufferOffsets.feed(b->binding, offset); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { - res[COMPUTE].buffers.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[COMPUTE].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[COMPUTE].buffers.feed(nativeBinding, mtlbuf); + res[COMPUTE].bufferOffsets.feed(b->binding, offset); + } } } break; diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index dc6060f882..0b99281f08 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -660,6 +660,13 @@ QDebug operator<<(QDebug dbg, const QShaderVersion &v) pair, because combined image samplers may map to two native resources (a texture and a sampler) in some shading languages. In that case the second value refers to the sampler. + + \note The native binding may be -1, in case there is no active binding for + the resource in the shader. (for example, there is a uniform block + declared, but it is not used in the shader code) The map is always + complete, meaning there is an entry for all declared uniform blocks, + storage blocks, image objects, and combined samplers, but the value will be + -1 for those that are not actually referenced in the shader functions. */ /*! -- cgit v1.2.3 From 83818431e15e36ad9c8484cee33475ba00731d6f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Dec 2019 14:13:03 +0100 Subject: rhi: gl: Add support for arrays of float, vec2, vec3 and vec4 This is a thing in Qt Quick: there are some types of image particles that use uniforms like "float opacitytable[64]". This should make all views work correctly in the Image Particles example when running on the OpenGL backend of QRhi. (other backends should work as expected already) Change-Id: I64a04fbb98b97d81d257b00b428582e751d46b8e Fixes: QTBUG-80667 Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhigles2.cpp | 79 +++++++++++++++++++++++++++++++++++++++------ src/gui/rhi/qrhigles2_p_p.h | 1 + 2 files changed, 70 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 3fb2ec38a7..ffaccbad71 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2378,12 +2378,23 @@ void QRhiGles2::executeBindGraphicsPipeline(QRhiGraphicsPipeline *ps) f->glUseProgram(psD->program); } +static inline void qrhi_std140_to_packed(float *dst, int vecSize, int elemCount, const void *src) +{ + const float *p = reinterpret_cast(src); + for (int i = 0; i < elemCount; ++i) { + for (int j = 0; j < vecSize; ++j) + dst[vecSize * i + j] = *p++; + p += 4 - vecSize; + } +} + void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiComputePipeline *maybeComputePs, QRhiShaderResourceBindings *srb, const uint *dynOfsPairs, int dynOfsCount) { QGles2ShaderResourceBindings *srbD = QRHI_RES(QGles2ShaderResourceBindings, srb); int texUnit = 0; + QVarLengthArray packedFloatArray; for (int i = 0, ie = srbD->m_bindings.count(); i != ie; ++i) { const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); @@ -2411,18 +2422,64 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC // so this should not cause unaligned reads const void *src = bufView.constData() + uniform.offset; + if (uniform.arrayDim > 0 + && uniform.type != QShaderDescription::Float + && uniform.type != QShaderDescription::Vec2 + && uniform.type != QShaderDescription::Vec3 + && uniform.type != QShaderDescription::Vec4) + { + qWarning("Uniform with buffer binding %d, buffer offset %d, type %d is an array, " + "but arrays are only supported for float, vec2, vec3, and vec4. " + "Only the first element will be set.", + uniform.binding, uniform.offset, uniform.type); + } + + // Our input is an std140 layout uniform block. See + // "Standard Uniform Block Layout" in section 7.6.2.2 of + // the OpenGL spec. This has some peculiar alignment + // requirements, which is not what glUniform* wants. Hence + // the unpacking/repacking for arrays and certain types. + switch (uniform.type) { case QShaderDescription::Float: - f->glUniform1f(uniform.glslLocation, *reinterpret_cast(src)); + { + const int elemCount = uniform.arrayDim; + if (elemCount < 1) { + f->glUniform1f(uniform.glslLocation, *reinterpret_cast(src)); + } else { + // input is 16 bytes per element as per std140, have to convert to packed + packedFloatArray.resize(elemCount); + qrhi_std140_to_packed(packedFloatArray.data(), 1, elemCount, src); + f->glUniform1fv(uniform.glslLocation, elemCount, packedFloatArray.constData()); + } + } break; case QShaderDescription::Vec2: - f->glUniform2fv(uniform.glslLocation, 1, reinterpret_cast(src)); + { + const int elemCount = uniform.arrayDim; + if (elemCount < 1) { + f->glUniform2fv(uniform.glslLocation, 1, reinterpret_cast(src)); + } else { + packedFloatArray.resize(elemCount * 2); + qrhi_std140_to_packed(packedFloatArray.data(), 2, elemCount, src); + f->glUniform2fv(uniform.glslLocation, elemCount, packedFloatArray.constData()); + } + } break; case QShaderDescription::Vec3: - f->glUniform3fv(uniform.glslLocation, 1, reinterpret_cast(src)); + { + const int elemCount = uniform.arrayDim; + if (elemCount < 1) { + f->glUniform3fv(uniform.glslLocation, 1, reinterpret_cast(src)); + } else { + packedFloatArray.resize(elemCount * 3); + qrhi_std140_to_packed(packedFloatArray.data(), 3, elemCount, src); + f->glUniform3fv(uniform.glslLocation, elemCount, packedFloatArray.constData()); + } + } break; case QShaderDescription::Vec4: - f->glUniform4fv(uniform.glslLocation, 1, reinterpret_cast(src)); + f->glUniform4fv(uniform.glslLocation, qMax(1, uniform.arrayDim), reinterpret_cast(src)); break; case QShaderDescription::Mat2: f->glUniformMatrix2fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast(src)); @@ -2477,8 +2534,9 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC case QShaderDescription::Bool4: f->glUniform4iv(uniform.glslLocation, 1, reinterpret_cast(src)); break; - // ### more types default: + qWarning("Uniform with buffer binding %d, buffer offset %d has unsupported type %d", + uniform.binding, uniform.offset, uniform.type); break; } } @@ -2944,9 +3002,15 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable const QByteArray name = namePrefix + var.name.toUtf8(); uniform.glslLocation = f->glGetUniformLocation(program, name.constData()); if (uniform.glslLocation >= 0) { + if (var.arrayDims.count() > 1) { + qWarning("Array '%s' has more than one dimension. This is not supported.", + qPrintable(var.name)); + return; + } uniform.binding = binding; uniform.offset = uint(baseOffset + var.offset); uniform.size = var.size; + uniform.arrayDim = var.arrayDims.isEmpty() ? 0 : var.arrayDims.first(); dst->append(uniform); } } @@ -2979,11 +3043,6 @@ void QRhiGles2::gatherUniforms(GLuint program, } } } else { - if (!blockMember.arrayDims.isEmpty()) { - qWarning("Arrays are only supported for structs at the moment. '%s' ignored.", - qPrintable(blockMember.name)); - continue; - } registerUniformIfActive(blockMember, prefix, ub.binding, 0, program, dst); } } diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index 4a98011d3d..d4f1336c3e 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -252,6 +252,7 @@ struct QGles2UniformDescription int binding; uint offset; int size; + int arrayDim; }; Q_DECLARE_TYPEINFO(QGles2UniformDescription, Q_MOVABLE_TYPE); -- cgit v1.2.3 From 026a8ec802361de4080b738db2bf6db85e047f76 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 10 Dec 2019 13:18:21 +0100 Subject: Move QOpenGLTimerQuery to from QtGui to QtOpenGL Task-number: QTBUG-74409 Change-Id: Ic8ef0a814700b2ed76b661d560907ad498334231 Reviewed-by: Laszlo Agocs --- src/gui/opengl/opengl.pri | 7 +- src/gui/opengl/qopenglqueryhelper_p.h | 186 ------- src/gui/opengl/qopengltimerquery.cpp | 880 ---------------------------------- src/gui/opengl/qopengltimerquery.h | 116 ----- 4 files changed, 2 insertions(+), 1187 deletions(-) delete mode 100644 src/gui/opengl/qopenglqueryhelper_p.h delete mode 100644 src/gui/opengl/qopengltimerquery.cpp delete mode 100644 src/gui/opengl/qopengltimerquery.h (limited to 'src/gui') diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index 9eab55f112..26060ea5df 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -85,9 +85,7 @@ qtConfig(opengl) { opengl/qopenglfunctions_4_2_compatibility.h \ opengl/qopenglfunctions_4_3_compatibility.h \ opengl/qopenglfunctions_4_4_compatibility.h \ - opengl/qopenglfunctions_4_5_compatibility.h \ - opengl/qopenglqueryhelper_p.h \ - opengl/qopengltimerquery.h + opengl/qopenglfunctions_4_5_compatibility.h SOURCES += opengl/qopenglfunctions_1_0.cpp \ opengl/qopenglfunctions_1_1.cpp \ @@ -114,8 +112,7 @@ qtConfig(opengl) { opengl/qopenglfunctions_4_2_compatibility.cpp \ opengl/qopenglfunctions_4_3_compatibility.cpp \ opengl/qopenglfunctions_4_4_compatibility.cpp \ - opengl/qopenglfunctions_4_5_compatibility.cpp \ - opengl/qopengltimerquery.cpp + opengl/qopenglfunctions_4_5_compatibility.cpp } qtConfig(opengles2) { diff --git a/src/gui/opengl/qopenglqueryhelper_p.h b/src/gui/opengl/qopenglqueryhelper_p.h deleted file mode 100644 index ad91ca9f96..0000000000 --- a/src/gui/opengl/qopenglqueryhelper_p.h +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLQUERYHELPER_P_H -#define QOPENGLQUERYHELPER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#if !defined(QT_OPENGL_ES_2) - -#include - -QT_BEGIN_NAMESPACE - -// Helper class used by QOpenGLTimerQuery and later will be used by -// QOpenGLOcclusionQuery -class QOpenGLQueryHelper -{ -public: - QOpenGLQueryHelper(QOpenGLContext *context) - : GetQueryObjectuiv(nullptr), - GetQueryObjectiv(nullptr), - GetQueryiv(nullptr), - EndQuery(nullptr), - BeginQuery(nullptr), - IsQuery(nullptr), - DeleteQueries(nullptr), - GenQueries(nullptr), - GetInteger64v(nullptr), - GetQueryObjectui64v(nullptr), - GetQueryObjecti64v(nullptr), - QueryCounter(nullptr) - { - Q_ASSERT(context); - - // Core in OpenGL >=1.5 - GetQueryObjectuiv = reinterpret_cast(context->getProcAddress("glGetQueryObjectuiv")); - GetQueryObjectiv = reinterpret_cast(context->getProcAddress("glGetQueryObjectiv")); - GetQueryiv = reinterpret_cast(context->getProcAddress("glGetQueryiv")); - EndQuery = reinterpret_cast(context->getProcAddress("glEndQuery")); - BeginQuery = reinterpret_cast(context->getProcAddress("glBeginQuery")); - IsQuery = reinterpret_cast(context->getProcAddress("glIsQuery")); - DeleteQueries = reinterpret_cast(context->getProcAddress("glDeleteQueries")); - GenQueries = reinterpret_cast(context->getProcAddress("glGenQueries")); - - // Core in OpenGL >=3.2 - GetInteger64v = reinterpret_cast(context->getProcAddress("glGetInteger64v")); - - // Core in OpenGL >=3.3 / ARB_timer_query - GetQueryObjectui64v = reinterpret_cast(context->getProcAddress("glGetQueryObjectui64v")); - GetQueryObjecti64v = reinterpret_cast(context->getProcAddress("glGetQueryObjecti64v")); - QueryCounter = reinterpret_cast(context->getProcAddress("glQueryCounter")); - } - - inline void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) - { - GetQueryObjectuiv(id, pname, params); - } - - inline void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) - { - GetQueryObjectiv(id, pname, params); - } - - inline void glGetQueryiv(GLenum target, GLenum pname, GLint *params) - { - GetQueryiv(target, pname, params); - } - - inline void glEndQuery(GLenum target) - { - EndQuery(target); - } - - inline void glBeginQuery(GLenum target, GLuint id) - { - BeginQuery(target, id); - } - - inline GLboolean glIsQuery(GLuint id) - { - return IsQuery(id); - } - - inline void glDeleteQueries(GLsizei n, const GLuint *ids) - { - DeleteQueries(n, ids); - } - - inline void glGenQueries(GLsizei n, GLuint *ids) - { - GenQueries(n, ids); - } - - inline void glGetInteger64v(GLenum pname, GLint64 *params) - { - GetInteger64v(pname, params); - } - - inline void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) - { - GetQueryObjectui64v(id, pname, params); - } - - inline void glGetQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) - { - GetQueryObjecti64v(id, pname, params); - } - - inline void glQueryCounter(GLuint id, GLenum target) - { - QueryCounter(id, target); - } - -private: - // Core in OpenGL >=1.5 - void (QOPENGLF_APIENTRYP GetQueryObjectuiv)(GLuint id, GLenum pname, GLuint *params); - void (QOPENGLF_APIENTRYP GetQueryObjectiv)(GLuint id, GLenum pname, GLint *params); - void (QOPENGLF_APIENTRYP GetQueryiv)(GLenum target, GLenum pname, GLint *params); - void (QOPENGLF_APIENTRYP EndQuery)(GLenum target); - void (QOPENGLF_APIENTRYP BeginQuery)(GLenum target, GLuint id); - GLboolean (QOPENGLF_APIENTRYP IsQuery)(GLuint id); - void (QOPENGLF_APIENTRYP DeleteQueries)(GLsizei n, const GLuint *ids); - void (QOPENGLF_APIENTRYP GenQueries)(GLsizei n, GLuint *ids); - - // Core in OpenGL >=3.2 - void (QOPENGLF_APIENTRYP GetInteger64v)(GLenum pname, GLint64 *params); - - // Core in OpenGL >=3.3 and provided by ARB_timer_query - void (QOPENGLF_APIENTRYP GetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 *params); - void (QOPENGLF_APIENTRYP GetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 *params); - void (QOPENGLF_APIENTRYP QueryCounter)(GLuint id, GLenum target); -}; - -QT_END_NAMESPACE - -#endif - -#endif // QOPENGLQUERYHELPER_P_H diff --git a/src/gui/opengl/qopengltimerquery.cpp b/src/gui/opengl/qopengltimerquery.cpp deleted file mode 100644 index a4e10b42f7..0000000000 --- a/src/gui/opengl/qopengltimerquery.cpp +++ /dev/null @@ -1,880 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qopengltimerquery.h" - -#include "qopenglqueryhelper_p.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -// Helper class used as fallback if OpenGL <3.3 is being used with EXT_timer_query -class QExtTimerQueryHelper -{ -public: - QExtTimerQueryHelper(QOpenGLContext *context) - { - Q_ASSERT(context); - GetQueryObjectui64vEXT = reinterpret_cast(context->getProcAddress("glGetQueryObjectui64vEXT")); - GetQueryObjecti64vEXT = reinterpret_cast(context->getProcAddress("glGetQueryObjecti64vEXT")); - } - - inline void glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) - { - GetQueryObjectui64vEXT(id, pname, params); - } - - inline void glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) - { - GetQueryObjecti64vEXT(id, pname, params); - } - -private: - void (QOPENGLF_APIENTRYP GetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64EXT *params); - void (QOPENGLF_APIENTRYP GetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64EXT *params); -}; - -class QOpenGLTimerQueryPrivate : public QObjectPrivate -{ -public: - QOpenGLTimerQueryPrivate() - : QObjectPrivate(), - context(nullptr), - ext(nullptr), - timeInterval(0), - timer(0) - { - } - - ~QOpenGLTimerQueryPrivate() - { - delete core; - delete ext; - } - - bool create(); - void destroy(); - void begin(); - void end(); - GLuint64 waitForTimeStamp() const; - void recordTimestamp(); - bool isResultAvailable() const; - GLuint64 result() const; - - // There are several cases we must handle: - // OpenGL >=3.3 includes timer queries as a core feature - // ARB_timer_query has same functionality as above. Requires OpenGL 3.2 - // EXT_timer_query offers limited support. Can be used with OpenGL >=1.5 - // - // Note that some implementations (OS X) provide OpenGL 3.2 but do not expose the - // ARB_timer_query extension. In such situations we must also be able to handle - // using the EXT_timer_query extension with any version of OpenGL. - // - // OpenGL 1.5 or above contains the generic query API and OpenGL 3.3 and - // ARB_timer_query provide the 64-bit query API. These are wrapped by - // QOpenGLQueryHelper. All we need to handle in addition is the EXT_timer_query - // case and to take care not to call the Core/ARB functions when we only - // have EXT_timer_query available. - QOpenGLContext *context; - QOpenGLQueryHelper *core; - QExtTimerQueryHelper *ext; - mutable GLuint64 timeInterval; - GLuint timer; -}; - -bool QOpenGLTimerQueryPrivate::create() -{ - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - - if (timer && context == ctx) - return true; - - context = ctx; - if (!context) { - qWarning("A current OpenGL context is required to create timer query objects"); - return false; - } - - if (context->isOpenGLES()) { - qWarning("QOpenGLTimerQuery: Not supported on OpenGL ES"); - return false; - } - - // Resolve the functions provided by OpenGL 1.5 and OpenGL 3.3 or ARB_timer_query - core = new QOpenGLQueryHelper(context); - - // Check to see if we also need to resolve the functions for EXT_timer_query - QSurfaceFormat f = context->format(); - if (f.version() <= qMakePair(3, 2) - && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) - && context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { - ext = new QExtTimerQueryHelper(context); - } else if (f.version() <= qMakePair(3, 2) - && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) - && !context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { - qWarning("QOpenGLTimerQuery requires one of:\n" - " OpenGL 3.3 or newer,\n" - " OpenGL 3.2 and the ARB_timer_query extension\n" - " or the EXT_timer query extension"); - return false; - } - - core->glGenQueries(1, &timer); - return (timer != 0); -} - -void QOpenGLTimerQueryPrivate::destroy() -{ - if (!timer) - return; - - core->glDeleteQueries(1, &timer); - timer = 0; - context = nullptr; -} - -// GL_TIME_ELAPSED_EXT is not defined on OS X 10.6 -#if !defined(GL_TIME_ELAPSED_EXT) -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -// GL_TIME_ELAPSED is not defined on OS X 10.7 or 10.8 yet -#if !defined(GL_TIME_ELAPSED) -#define GL_TIME_ELAPSED GL_TIME_ELAPSED_EXT -#endif - -void QOpenGLTimerQueryPrivate::begin() -{ - core->glBeginQuery(GL_TIME_ELAPSED, timer); -} - -void QOpenGLTimerQueryPrivate::end() -{ - core->glEndQuery(GL_TIME_ELAPSED); -} - -void QOpenGLTimerQueryPrivate::recordTimestamp() -{ - // Don't call glQueryCounter if we only have EXT_timer_query -#if defined(GL_TIMESTAMP) - if (!ext) - core->glQueryCounter(timer, GL_TIMESTAMP); - else - qWarning("QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); -#else - qWarning("QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); -#endif -} - -GLuint64 QOpenGLTimerQueryPrivate::waitForTimeStamp() const -{ - GLint64 tmp = 0; -#if defined(GL_TIMESTAMP) - if (!ext) - core->glGetInteger64v(GL_TIMESTAMP, &tmp); - else - qWarning("QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); -#else - qWarning("QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); -#endif - GLuint64 timestamp(tmp); - return timestamp; -} - -bool QOpenGLTimerQueryPrivate::isResultAvailable() const -{ - GLuint available = GL_FALSE; - core->glGetQueryObjectuiv(timer, GL_QUERY_RESULT_AVAILABLE, &available); - return available; -} - -GLuint64 QOpenGLTimerQueryPrivate::result() const -{ - if (!ext) - core->glGetQueryObjectui64v(timer, GL_QUERY_RESULT, &timeInterval); - else - ext->glGetQueryObjectui64vEXT(timer, GL_QUERY_RESULT, &timeInterval); - return timeInterval; -} - -/*! - \class QOpenGLTimerQuery - \brief The QOpenGLTimerQuery class wraps an OpenGL timer query object. - \inmodule QtGui - \since 5.1 - \ingroup painting-3D - - OpenGL timer query objects are OpenGL managed resources to measure the - execution times of sequences of OpenGL commands on the GPU. - - OpenGL offers various levels of support for timer queries, depending on - the version of OpenGL you have and the presence of the ARB_timer_query or - EXT_timer_query extensions. The support can be summarized as: - - \list - \li OpenGL >=3.3 offers full support for all timer query functionality. - \li OpenGL 3.2 with the ARB_timer_query extension offers full support - for all timer query functionality. - \li OpenGL <=3.2 with the EXT_timer_query extension offers limited support - in that the timestamp of the GPU cannot be queried. Places where this - impacts functions provided by Qt classes will be highlighted in the - function documentation. - \li OpenGL ES 2 (and OpenGL ES 3) do not provide any support for OpenGL - timer queries. - \endlist - - OpenGL represents time with a granularity of 1 nanosecond (1e-9 seconds). As a - consequence of this, 32-bit integers would only give a total possible duration - of approximately 4 seconds, which would not be difficult to exceed in poorly - performing or lengthy operations. OpenGL therefore uses 64 bit integer types - to represent times. A GLuint64 variable has enough width to contain a duration - of hundreds of years, which is plenty for real-time rendering needs. - - As with the other Qt OpenGL classes, QOpenGLTimerQuery has a create() - function to create the underlying OpenGL object. This is to allow the developer to - ensure that there is a valid current OpenGL context at the time. - - Once created, timer queries can be issued in one of several ways. The simplest - method is to delimit a block of commands with calls to begin() and end(). This - instructs OpenGL to measure the time taken from completing all commands issued - prior to begin() until the completion of all commands issued prior to end(). - - At the end of a frame we can retrieve the results by calling waitForResult(). - As this function's name implies, it blocks CPU execution until OpenGL notifies - that the timer query result is available. To avoid blocking, you can check - if the query result is available by calling isResultAvailable(). Note that - modern GPUs are deeply pipelined and query results may not become available for - between 1-5 frames after they were issued. - - Note that OpenGL does not permit nesting or interleaving of multiple timer queries - using begin() and end(). Using multiple timer queries and recordTimestamp() avoids - this limitation. When using recordTimestamp() the result can be obtained at - some later time using isResultAvailable() and waitForResult(). Qt provides the - convenience class QOpenGLTimeMonitor that helps with using multiple query objects. - - \sa QOpenGLTimeMonitor -*/ - -/*! - Creates a QOpenGLTimerQuery instance with the given \a parent. You must call create() - with a valid OpenGL context before using. -*/ -QOpenGLTimerQuery::QOpenGLTimerQuery(QObject *parent) - : QObject(*new QOpenGLTimerQueryPrivate, parent) -{ -} - -/*! - Destroys the QOpenGLTimerQuery and the underlying OpenGL resource. -*/ -QOpenGLTimerQuery::~QOpenGLTimerQuery() -{ - QOpenGLContext* ctx = QOpenGLContext::currentContext(); - - Q_D(QOpenGLTimerQuery); - QOpenGLContext *oldContext = nullptr; - if (d->context != ctx) { - oldContext = ctx; - if (d->context->makeCurrent(oldContext->surface())) { - ctx = d->context; - } else { - qWarning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to make query objects's context current"); - ctx = nullptr; - } - } - - if (ctx) - destroy(); - - if (oldContext) { - if (!oldContext->makeCurrent(oldContext->surface())) - qWarning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to restore current context"); - } -} - -/*! - Creates the underlying OpenGL timer query object. There must be a valid OpenGL context - that supports query objects current for this function to succeed. - - Returns \c true if the OpenGL timer query object was successfully created. -*/ -bool QOpenGLTimerQuery::create() -{ - Q_D(QOpenGLTimerQuery); - return d->create(); -} - -/*! - Destroys the underlying OpenGL timer query object. The context that was current when - create() was called must be current when calling this function. -*/ -void QOpenGLTimerQuery::destroy() -{ - Q_D(QOpenGLTimerQuery); - d->destroy(); -} - -/*! - Returns \c true if the underlying OpenGL query object has been created. If this - returns \c true and the associated OpenGL context is current, then you are able to issue - queries with this object. -*/ -bool QOpenGLTimerQuery::isCreated() const -{ - Q_D(const QOpenGLTimerQuery); - return (d->timer != 0); -} - -/*! - Returns the id of the underlying OpenGL query object. -*/ -GLuint QOpenGLTimerQuery::objectId() const -{ - Q_D(const QOpenGLTimerQuery); - return d->timer; -} - -/*! - Marks the start point in the OpenGL command queue for a sequence of commands to - be timed by this query object. - - This is useful for simple use-cases. Usually it is better to use recordTimestamp(). - - \sa end(), isResultAvailable(), waitForResult(), recordTimestamp() -*/ -void QOpenGLTimerQuery::begin() -{ - Q_D(QOpenGLTimerQuery); - d->begin(); -} - -/*! - Marks the end point in the OpenGL command queue for a sequence of commands to - be timed by this query object. - - This is useful for simple use-cases. Usually it is better to use recordTimestamp(). - - \sa begin(), isResultAvailable(), waitForResult(), recordTimestamp() -*/ -void QOpenGLTimerQuery::end() -{ - Q_D(QOpenGLTimerQuery); - d->end(); -} - -/*! - Places a marker in the OpenGL command queue for the GPU to record the timestamp - when this marker is reached by the GPU. This function is non-blocking and the - result will become available at some later time. - - The availability of the result can be checked with isResultAvailable(). The result - can be fetched with waitForResult() which will block if the result is not yet - available. - - \sa waitForResult(), isResultAvailable(), begin(), end() -*/ -void QOpenGLTimerQuery::recordTimestamp() -{ - Q_D(QOpenGLTimerQuery); - return d->recordTimestamp(); -} - -/*! - Returns the current timestamp of the GPU when all previously issued OpenGL - commands have been received but not necessarily executed by the GPU. - - This function blocks until the result is returned. - - \sa recordTimestamp() -*/ -GLuint64 QOpenGLTimerQuery::waitForTimestamp() const -{ - Q_D(const QOpenGLTimerQuery); - return d->waitForTimeStamp(); -} - -/*! - Returns \c true if the OpenGL timer query result is available. - - This function is non-blocking and ideally should be used to check for the - availability of the query result before calling waitForResult(). - - \sa waitForResult() -*/ -bool QOpenGLTimerQuery::isResultAvailable() const -{ - Q_D(const QOpenGLTimerQuery); - return d->isResultAvailable(); -} - -/*! - Returns the result of the OpenGL timer query. - - This function will block until the result is made available by OpenGL. It is - recommended to call isResultAvailable() to ensure that the result is available - to avoid unnecessary blocking and stalling. - - \sa isResultAvailable() -*/ -GLuint64 QOpenGLTimerQuery::waitForResult() const -{ - Q_D(const QOpenGLTimerQuery); - return d->result(); -} - - -class QOpenGLTimeMonitorPrivate : public QObjectPrivate -{ -public: - QOpenGLTimeMonitorPrivate() - : QObjectPrivate(), - timers(), - timeSamples(), - context(nullptr), - core(nullptr), - ext(nullptr), - requestedSampleCount(2), - currentSample(-1), - timerQueryActive(false) - { - } - - ~QOpenGLTimeMonitorPrivate() - { - delete core; - delete ext; - } - - bool create(); - void destroy(); - void recordSample(); - bool isResultAvailable() const; - QVector samples() const; - QVector intervals() const; - void reset(); - - QVector timers; - mutable QVector timeSamples; - - QOpenGLContext *context; - QOpenGLQueryHelper *core; - QExtTimerQueryHelper *ext; - - int requestedSampleCount; - int currentSample; - mutable bool timerQueryActive; -}; - -bool QOpenGLTimeMonitorPrivate::create() -{ - if (!timers.isEmpty() && timers.at(0) != 0 && timers.size() == requestedSampleCount) - return true; - - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - if (context && context != ctx) { - qWarning("QTimeMonitor: Attempting to use different OpenGL context to recreate timers.\n" - "Please call destroy() first or use the same context to previously create"); - return false; - } - - context = ctx; - if (!context) { - qWarning("A current OpenGL context is required to create timer query objects"); - return false; - } - - // Resize the vectors that hold the timers and the recorded samples - timers.resize(requestedSampleCount); - timeSamples.resize(requestedSampleCount); - - // Resolve the functions provided by OpenGL 1.5 and OpenGL 3.3 or ARB_timer_query - core = new QOpenGLQueryHelper(context); - - // Check to see if we also need to resolve the functions for EXT_timer_query - QSurfaceFormat f = context->format(); - if (f.version() <= qMakePair(3, 2) - && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) - && context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { - ext = new QExtTimerQueryHelper(context); - } else if (f.version() <= qMakePair(3, 2) - && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) - && !context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { - qWarning("QOpenGLTimeMonitor requires one of:\n" - " OpenGL 3.3 or newer,\n" - " OpenGL 3.2 and the ARB_timer_query extension\n" - " or the EXT_timer query extension"); - return false; - } - - core->glGenQueries(requestedSampleCount, timers.data()); - return (timers.at(0) != 0); -} - -void QOpenGLTimeMonitorPrivate::destroy() -{ - if (timers.isEmpty() || timers.at(0) == 0) - return; - - core->glDeleteQueries(timers.size(), timers.data()); - timers.clear(); - delete core; - core = nullptr; - delete ext; - ext = nullptr; - context = nullptr; -} - -void QOpenGLTimeMonitorPrivate::recordSample() -{ - // Use glQueryCounter() and GL_TIMESTAMP where available. - // Otherwise, simulate it with glBeginQuery()/glEndQuery() - if (!ext) { -#if defined(GL_TIMESTAMP) - core->glQueryCounter(timers.at(++currentSample), GL_TIMESTAMP); -#endif - } else { - if (currentSample == -1) { - core->glBeginQuery(GL_TIME_ELAPSED_EXT, timers.at(++currentSample)); - timerQueryActive = true; - } else if (currentSample < timers.size() - 1) { - core->glEndQuery(GL_TIME_ELAPSED_EXT); - core->glBeginQuery(GL_TIME_ELAPSED_EXT, timers.at(++currentSample)); - } else { - if (timerQueryActive) { - core->glEndQuery(GL_TIME_ELAPSED_EXT); - timerQueryActive = false; - } - } - } -} - -bool QOpenGLTimeMonitorPrivate::isResultAvailable() const -{ - // The OpenGL spec says that if a query result is ready then the results of all queries - // of the same type issued before it must also be ready. Therefore we only need to check - // the availability of the result for the last issued query - GLuint available = GL_FALSE; - core->glGetQueryObjectuiv(timers.at(currentSample), GL_QUERY_RESULT_AVAILABLE, &available); - return available; -} - -QVector QOpenGLTimeMonitorPrivate::samples() const -{ - // For the Core and ARB options just ask for the timestamp for each timer query. - // For the EXT implementation we cannot obtain timestamps so we defer any result - // collection to the intervals() function - if (!ext) { - for (int i = 0; i <= currentSample; ++i) - core->glGetQueryObjectui64v(timers.at(i), GL_QUERY_RESULT, &timeSamples[i]); - } else { - qWarning("QOpenGLTimeMonitor::samples() requires OpenGL >=3.3\n" - "or OpenGL 3.2 and GL_ARB_timer_query"); - } - return timeSamples; -} - -QVector QOpenGLTimeMonitorPrivate::intervals() const -{ - QVector intervals(timers.size() - 1); - if (!ext) { - // Obtain the timestamp samples and calculate the interval durations - const QVector timeStamps = samples(); - for (int i = 0; i < intervals.size(); ++i) - intervals[i] = timeStamps[i+1] - timeStamps[i]; - } else { - // Stop the last timer if needed - if (timerQueryActive) { - core->glEndQuery(GL_TIME_ELAPSED_EXT); - timerQueryActive = false; - } - - // Obtain the results from all timers apart from the redundant last one. In this - // case the results actually are the intervals not timestamps - for (int i = 0; i < currentSample; ++i) - ext->glGetQueryObjectui64vEXT(timers.at(i), GL_QUERY_RESULT, &intervals[i]); - } - - return intervals; -} - -void QOpenGLTimeMonitorPrivate::reset() -{ - currentSample = -1; - timeSamples.fill(0); -} - - -/*! - \class QOpenGLTimeMonitor - \brief The QOpenGLTimeMonitor class wraps a sequence of OpenGL timer query objects. - \inmodule QtGui - \since 5.1 - \ingroup painting-3D - - The QOpenGLTimeMonitor class is a convenience wrapper around a collection of OpenGL - timer query objects used to measure intervals of time on the GPU to the level of - granularity required by your rendering application. - - The OpenGL timer queries objects are queried in sequence to record the GPU - timestamps at positions of interest in your rendering code. Once the results for - all issues timer queries become available, the results can be fetched and - QOpenGLTimerMonitor will calculate the recorded time intervals for you. - - The typical use case of this class is to either profile your application's rendering - algorithms or to adjust those algorithms in real-time for dynamic performance/quality - balancing. - - Prior to using QOpenGLTimeMonitor in your rendering function you should set the - required number of sample points that you wish to record by calling setSamples(). Note - that measuring N sample points will produce N-1 time intervals. Once you have set the - number of sample points, call the create() function with a valid current OpenGL context - to create the necessary query timer objects. These steps are usually performed just - once in an initialization function. - - Use the recordSample() function to delimit blocks of code containing OpenGL commands - that you wish to time. You can check availability of the resulting time - samples and time intervals with isResultAvailable(). The calculated time intervals and - the raw timestamp samples can be retrieved with the blocking waitForIntervals() and - waitForSamples() functions respectively. - - After retrieving the results and before starting a new round of taking samples - (for example, in the next frame) be sure to call the reset() function which will clear - the cached results and reset the timer index back to the first timer object. - - \sa QOpenGLTimerQuery -*/ - -/*! - Creates a QOpenGLTimeMonitor instance with the given \a parent. You must call create() - with a valid OpenGL context before using. - - \sa setSampleCount(), create() -*/ -QOpenGLTimeMonitor::QOpenGLTimeMonitor(QObject *parent) - : QObject(*new QOpenGLTimeMonitorPrivate, parent) -{ -} - -/*! - Destroys the QOpenGLTimeMonitor and any underlying OpenGL resources. -*/ -QOpenGLTimeMonitor::~QOpenGLTimeMonitor() -{ - QOpenGLContext* ctx = QOpenGLContext::currentContext(); - - Q_D(QOpenGLTimeMonitor); - QOpenGLContext *oldContext = nullptr; - if (d->context != ctx) { - oldContext = ctx; - if (d->context->makeCurrent(oldContext->surface())) { - ctx = d->context; - } else { - qWarning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to make time monitor's context current"); - ctx = nullptr; - } - } - - if (ctx) - destroy(); - - if (oldContext) { - if (!oldContext->makeCurrent(oldContext->surface())) - qWarning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to restore current context"); - } -} - -/*! - Sets the number of sample points to \a sampleCount. After setting the number - of samples with this function, you must call create() to instantiate the underlying - OpenGL timer query objects. - - The new \a sampleCount must be at least 2. - - \sa sampleCount(), create(), recordSample() -*/ -void QOpenGLTimeMonitor::setSampleCount(int sampleCount) -{ - // We need at least 2 samples to get an interval - if (sampleCount < 2) - return; - Q_D(QOpenGLTimeMonitor); - d->requestedSampleCount = sampleCount; -} - -/*! - Returns the number of sample points that have been requested with - setSampleCount(). If create was successfully called following setSampleCount(), - then the value returned will be the actual number of sample points - that can be used. - - The default value for sample count is 2, leading to the measurement of a - single interval. - - \sa setSampleCount() -*/ -int QOpenGLTimeMonitor::sampleCount() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->requestedSampleCount; -} - -/*! - Instantiate sampleCount() OpenGL timer query objects that will be used - to track the amount of time taken to execute OpenGL commands between - successive calls to recordSample(). - - Returns \c true if the OpenGL timer query objects could be created. - - \sa destroy(), setSampleCount(), recordSample() -*/ -bool QOpenGLTimeMonitor::create() -{ - Q_D(QOpenGLTimeMonitor); - return d->create(); -} - -/*! - Destroys any OpenGL timer query objects used within this instance. - - \sa create() -*/ -void QOpenGLTimeMonitor::destroy() -{ - Q_D(QOpenGLTimeMonitor); - d->destroy(); -} - -/*! - Returns \c true if the underlying OpenGL query objects have been created. If this - returns \c true and the associated OpenGL context is current, then you are able to record - time samples with this object. -*/ -bool QOpenGLTimeMonitor::isCreated() const -{ - Q_D(const QOpenGLTimeMonitor); - return (!d->timers.isEmpty() && d->timers.at(0) != 0); -} - -/*! - Returns a QVector containing the object Ids of the OpenGL timer query objects. -*/ -QVector QOpenGLTimeMonitor::objectIds() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->timers; -} - -/*! - Issues an OpenGL timer query at this point in the OpenGL command queue. Calling this - function in a sequence in your application's rendering function, will build up - details of the GPU time taken to execute the OpenGL commands between successive - calls to this function. - - \sa setSampleCount(), isResultAvailable(), waitForSamples(), waitForIntervals() -*/ -int QOpenGLTimeMonitor::recordSample() -{ - Q_D(QOpenGLTimeMonitor); - d->recordSample(); - return d->currentSample; -} - -/*! - Returns \c true if the OpenGL timer query results are available. - - \sa waitForSamples(), waitForIntervals() -*/ -bool QOpenGLTimeMonitor::isResultAvailable() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->isResultAvailable(); -} - -/*! - Returns a QVector containing the GPU timestamps taken with recordSample(). - - This function will block until OpenGL indicates the results are available. It - is recommended to check the availability of the result prior to calling this - function with isResultAvailable(). - - \note This function only works on systems that have OpenGL >=3.3 or the - ARB_timer_query extension. See QOpenGLTimerQuery for more details. - - \sa waitForIntervals(), isResultAvailable() -*/ -QVector QOpenGLTimeMonitor::waitForSamples() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->samples(); -} - -/*! - Returns a QVector containing the time intervals delimited by the calls to - recordSample(). The resulting vector will contain one fewer element as - this represents the intervening intervals rather than the actual timestamp - samples. - - This function will block until OpenGL indicates the results are available. It - is recommended to check the availability of the result prior to calling this - function with isResultAvailable(). - - \sa waitForSamples(), isResultAvailable() -*/ -QVector QOpenGLTimeMonitor::waitForIntervals() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->intervals(); -} - -/*! - Resets the time monitor ready for use in another frame of rendering. Call - this once you have obtained the previous results and before calling - recordSample() for the first time on the next frame. - - \sa recordSample() -*/ -void QOpenGLTimeMonitor::reset() -{ - Q_D(QOpenGLTimeMonitor); - d->reset(); -} - -QT_END_NAMESPACE diff --git a/src/gui/opengl/qopengltimerquery.h b/src/gui/opengl/qopengltimerquery.h deleted file mode 100644 index 27da74a3fb..0000000000 --- a/src/gui/opengl/qopengltimerquery.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLTIMERQUERY_H -#define QOPENGLTIMERQUERY_H - -#include - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) - -#include -#include - -QT_BEGIN_NAMESPACE - -class QOpenGLTimerQueryPrivate; - -class Q_GUI_EXPORT QOpenGLTimerQuery : public QObject -{ - Q_OBJECT - -public: - explicit QOpenGLTimerQuery(QObject *parent = nullptr); - ~QOpenGLTimerQuery(); - - bool create(); - void destroy(); - bool isCreated() const; - GLuint objectId() const; - - void begin(); - void end(); - GLuint64 waitForTimestamp() const; - void recordTimestamp(); - bool isResultAvailable() const; - GLuint64 waitForResult() const; - -private: - Q_DECLARE_PRIVATE(QOpenGLTimerQuery) - Q_DISABLE_COPY(QOpenGLTimerQuery) -}; - - -class QOpenGLTimeMonitorPrivate; - -class Q_GUI_EXPORT QOpenGLTimeMonitor : public QObject -{ - Q_OBJECT - -public: - explicit QOpenGLTimeMonitor(QObject *parent = nullptr); - ~QOpenGLTimeMonitor(); - - void setSampleCount(int sampleCount); - int sampleCount() const; - - bool create(); - void destroy(); - bool isCreated() const; - QVector objectIds() const; - - int recordSample(); - - bool isResultAvailable() const; - - QVector waitForSamples() const; - QVector waitForIntervals() const; - - void reset(); - -private: - Q_DECLARE_PRIVATE(QOpenGLTimeMonitor) - Q_DISABLE_COPY(QOpenGLTimeMonitor) -}; - -QT_END_NAMESPACE - -#endif // QT_NO_OPENGL - -#endif // QOPENGLTIMERQUERY_H -- cgit v1.2.3 From 6f5556e7b4d5d388805d06d852b5cdb7c52e80dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 27 Nov 2019 17:16:50 +0100 Subject: QTextDocument: Change use of QMap::unite to QMap::insert None of the code I could see handles the map like a multimap. Change-Id: I9d51da6dafed4317e801703599e83fb038c22a1d Reviewed-by: Volker Hilsheimer Reviewed-by: Lars Knoll --- src/gui/text/qtextdocument.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 1d27cc30eb..f2caedc25f 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -3085,7 +3085,7 @@ void QTextDocumentPrivate::mergeCachedResources(const QTextDocumentPrivate *priv if (!priv) return; - cachedResources.unite(priv->cachedResources); + cachedResources.insert(priv->cachedResources); } void QTextHtmlExporter::emitBackgroundAttribute(const QTextFormat &format) -- cgit v1.2.3 From a3a6f28427de260ab827fc405b53b6f162f1ec90 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 13 Dec 2019 12:04:14 +0100 Subject: OpenGL: Fix signature of GLDEBUGPROC in qopenglextrafunctions.h The typedef "QOPENGLF_APIENTRYP" was incompatible to the one in "src/opengl/qopengldebug.cpp" which used "QOPENGLF_APIENTRY". Note the misisng "P " ending. The type is meant to be a function pointer, not a pointer to a function pointer, so remove the extra P. Change-Id: I229b73ca8e7367f88a2b48e2728e615605f02da3 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglextrafunctions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/opengl/qopenglextrafunctions.h b/src/gui/opengl/qopenglextrafunctions.h index a68e269065..faac2dce4e 100644 --- a/src/gui/opengl/qopenglextrafunctions.h +++ b/src/gui/opengl/qopenglextrafunctions.h @@ -54,7 +54,7 @@ // GLES build without having included gl32.h -> GLDEBUGPROC is still need for the protos, define it here #if defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_ES_3_2) -typedef void (QOPENGLF_APIENTRYP *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +typedef void (QOPENGLF_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); #endif QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 4522b17159a29ffd12c4d93be8a6e8e1a05dccd0 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 6 Dec 2019 21:56:41 +0100 Subject: QStandardItemModel: do not reset persisten index in setItem() When an existing item is replaced with a new one in QStandardItemModel::setItem() then the persitent index is invalidated which leads to some unexpected behaviors (like e.g the header size and resize mode are reset). Therefore we have to make sure that the invalidation does not happen. This can be achieved by delaying the call to QStandardItem::setModel() for the old item until the new is properly added. After this, the old item no longer gets a valid QModelIndex from the model and therefore can't invalidate the persistent index anymore. Fixes: QTBUG-13605 Fixes: QTBUG-73000 Fixes: QTBUG-80586 Change-Id: I4e45e6feb81b7287c0859f638d7ab1a576fc2f0f Reviewed-by: David Faure --- src/gui/itemmodels/qstandarditemmodel.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 2998808b54..9bdc22b49e 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -138,10 +138,19 @@ void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, return; } } + + // setting the model to nullptr invalidates the persistent index which we want to avoid + if (!item && oldItem) + oldItem->d_func()->setModel(nullptr); + + children.replace(index, item); + + // since now indexFromItem() does no longer return a valid index, the persistent index + // will not be invalidated anymore if (oldItem) oldItem->d_func()->setModel(nullptr); delete oldItem; - children.replace(index, item); + if (item) item->d_func()->lastKnownIndex = index; -- cgit v1.2.3 From 5b4b437b30b320e2cd7c9a566999a39772e5d431 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 10 Jun 2019 15:57:52 +0200 Subject: WebGradients: redo implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous implementation was *extremely* expensive. It relied on loading a binary JSON file from resources (which involved decompressing it), then extracting information out of it to build a gradient. Already-loaded gradients were kept in a local cache, which had to be mutex protected. Instead, this patch extends the gradient generator to build static arrays filled with the web gradient data, sitting in .rodata. These arrays are used when building QGradient objects with a web gradient. No explicit mutex protection is necessary, since accesses will just read from the arrays. As benefits, this patch removes: * the binary json representation from QtGui's resources (~4KB compressed, ~50KB uncompressed) * the overhead of reading from the JSON for each used web gradient; * the startup costs of registering the webgradients in the resources; * all the overhead of mutex locking when building such gradients; * all the runtime memory allocations to load, parse and cache the web gradients (including the memory + CPU spike on first load due to the uncompression of the JSON data, as well as a couple of deep copies). Change-Id: If5c3d704430df76ce8faf55ee75ebd4639ba09c4 Reviewed-by: Tor Arne Vestbø Reviewed-by: Ulf Hermann Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne --- src/gui/painting/WEBGRADIENTS_LICENSE.txt | 21 - src/gui/painting/painting.pri | 5 - src/gui/painting/qbrush.cpp | 55 +- src/gui/painting/qbrush.h | 24 +- src/gui/painting/qt_attribution.json | 14 - src/gui/painting/webgradients.binaryjson | Bin 50792 -> 0 bytes src/gui/painting/webgradients.cpp | 578 +++++++++++++++++++ src/gui/painting/webgradients.css | 909 ------------------------------ 8 files changed, 600 insertions(+), 1006 deletions(-) delete mode 100644 src/gui/painting/WEBGRADIENTS_LICENSE.txt delete mode 100644 src/gui/painting/webgradients.binaryjson create mode 100644 src/gui/painting/webgradients.cpp delete mode 100644 src/gui/painting/webgradients.css (limited to 'src/gui') diff --git a/src/gui/painting/WEBGRADIENTS_LICENSE.txt b/src/gui/painting/WEBGRADIENTS_LICENSE.txt deleted file mode 100644 index 1a4d527a4d..0000000000 --- a/src/gui/painting/WEBGRADIENTS_LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 itmeo - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index fcf6488edd..1a0f4f11e4 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -111,13 +111,8 @@ SOURCES += \ painting/qplatformbackingstore.cpp \ painting/qpathsimplifier.cpp -webgradients.files = painting/webgradients.binaryjson -webgradients.prefix = qgradient -webgradients.base = painting - RESOURCES += \ painting/qpdf.qrc \ - webgradients darwin { HEADERS += painting/qcoregraphics_p.h diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index b23fb45952..83032bdc4f 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -1347,6 +1348,8 @@ QGradient::QGradient() based on the gradients from https://webgradients.com/. */ +#include "webgradients.cpp" + /*! \fn QGradient::QGradient(QGradient::Preset preset) \since 5.12 @@ -1358,47 +1361,12 @@ QGradient::QGradient() to be applied to arbitrary object sizes. */ QGradient::QGradient(Preset preset) - : QGradient() -{ - static QHash cachedPresets; - static QMutex cacheMutex; - QMutexLocker locker(&cacheMutex); - if (cachedPresets.contains(preset)) { - const QGradient &cachedPreset = cachedPresets.value(preset); - m_type = cachedPreset.m_type; - m_data = cachedPreset.m_data; - m_stops = cachedPreset.m_stops; - m_spread = cachedPreset.m_spread; - dummy = cachedPreset.dummy; - } else { - static QJsonDocument jsonPresets = []() { - QFile webGradients(QLatin1String(":/qgradient/webgradients.binaryjson")); - webGradients.open(QFile::ReadOnly); - return QJsonDocument::fromBinaryData(webGradients.readAll()); - }(); - - const QJsonValue presetData = jsonPresets[preset - 1]; - if (!presetData.isObject()) - return; - - m_type = LinearGradient; - setCoordinateMode(ObjectMode); - setSpread(PadSpread); - - const QJsonValue start = presetData[QLatin1String("start")]; - const QJsonValue end = presetData[QLatin1String("end")]; - m_data.linear.x1 = start[QLatin1String("x")].toDouble(); - m_data.linear.y1 = start[QLatin1String("y")].toDouble(); - m_data.linear.x2 = end[QLatin1String("x")].toDouble(); - m_data.linear.y2 = end[QLatin1String("y")].toDouble(); - - for (const QJsonValue &stop : presetData[QLatin1String("stops")].toArray()) { - setColorAt(stop[QLatin1String("position")].toDouble(), - QColor(QRgb(stop[QLatin1String("color")].toInt()))); - } - - cachedPresets.insert(preset, *this); - } + : m_type(LinearGradient) + , m_spread(PadSpread) + , m_stops(qt_preset_gradient_stops(preset)) + , m_data(qt_preset_gradient_data[preset - 1]) + , dummy(qt_preset_gradient_dummy()) +{ } /*! @@ -1408,11 +1376,6 @@ QGradient::~QGradient() { } -QT_END_NAMESPACE -static void initGradientPresets() { Q_INIT_RESOURCE(qmake_webgradients); } -Q_CONSTRUCTOR_FUNCTION(initGradientPresets); -QT_BEGIN_NAMESPACE - /*! \enum QGradient::Type diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index 6a4ffab1c5..1d7199782f 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -400,16 +400,7 @@ public: inline bool operator!=(const QGradient &other) const { return !operator==(other); } -private: - friend class QLinearGradient; - friend class QRadialGradient; - friend class QConicalGradient; - friend class QBrush; - - Type m_type; - Spread m_spread; - QGradientStops m_stops; - union { + union QGradientData { struct { qreal x1, y1, x2, y2; } linear; @@ -419,7 +410,18 @@ private: struct { qreal cx, cy, angle; } conical; - } m_data; + }; + +private: + friend class QLinearGradient; + friend class QRadialGradient; + friend class QConicalGradient; + friend class QBrush; + + Type m_type; + Spread m_spread; + QGradientStops m_stops; + QGradientData m_data; void *dummy; // ### Qt 6: replace with actual content (CoordinateMode, InterpolationMode, ...) }; diff --git a/src/gui/painting/qt_attribution.json b/src/gui/painting/qt_attribution.json index 7b16e8c211..e2326a56c1 100644 --- a/src/gui/painting/qt_attribution.json +++ b/src/gui/painting/qt_attribution.json @@ -28,20 +28,6 @@ (C) Carsten Haitzler and various contributors. (C) Willem Monsuwe " }, - { - "Id": "webgradients", - "Name": "WebGradients", - "QDocModule": "qtgui", - "QtUsage": "Used in Qt GUI to provide presets for QGradient.", - "Files": "webgradients.css", - - "Description": "WebGradients is a free collection of 180 linear gradients.", - "Homepage": "https://webgradients.com/", - "License": "MIT License", - "LicenseId": "MIT", - "LicenseFile": "WEBGRADIENTS_LICENSE.txt", - "Copyright": "Copyright (c) 2017 itmeo" - }, { "Id": "xserverhelper", "Name": "X Server helper", diff --git a/src/gui/painting/webgradients.binaryjson b/src/gui/painting/webgradients.binaryjson deleted file mode 100644 index 75edd487be..0000000000 Binary files a/src/gui/painting/webgradients.binaryjson and /dev/null differ diff --git a/src/gui/painting/webgradients.cpp b/src/gui/painting/webgradients.cpp new file mode 100644 index 0000000000..b4d297450b --- /dev/null +++ b/src/gui/painting/webgradients.cpp @@ -0,0 +1,578 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file is auto-generated by gradientgen. DO NOT EDIT! + +static QArrayDataPointerRef qt_preset_gradient_stops(QGradient::Preset preset) +{ + Q_ASSERT(preset < QGradient::NumPresets); + switch (preset) { + case QGradient::WarmFlame: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 154, 158, 255)), QGradientStop(0.99, QColor(250, 208, 196, 255)), QGradientStop(1, QColor(250, 208, 196, 255))); + case QGradient::NightFade: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(161, 140, 209, 255)), QGradientStop(1, QColor(251, 194, 235, 255))); + case QGradient::SpringWarmth: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(250, 208, 196, 255)), QGradientStop(0.01, QColor(250, 208, 196, 255)), QGradientStop(1, QColor(255, 209, 255, 255))); + case QGradient::JuicyPeach: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 236, 210, 255)), QGradientStop(1, QColor(252, 182, 159, 255))); + case QGradient::YoungPassion: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 129, 119, 255)), QGradientStop(0, QColor(255, 134, 122, 255)), QGradientStop(0.21, QColor(255, 140, 127, 255)), QGradientStop(0.52, QColor(249, 145, 133, 255)), QGradientStop(0.78, QColor(207, 85, 108, 255)), QGradientStop(1, QColor(177, 42, 91, 255))); + case QGradient::LadyLips: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 154, 158, 255)), QGradientStop(0.99, QColor(254, 207, 239, 255)), QGradientStop(1, QColor(254, 207, 239, 255))); + case QGradient::SunnyMorning: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(246, 211, 101, 255)), QGradientStop(1, QColor(253, 160, 133, 255))); + case QGradient::RainyAshville: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(251, 194, 235, 255)), QGradientStop(1, QColor(166, 193, 238, 255))); + case QGradient::FrozenDreams: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(253, 203, 241, 255)), QGradientStop(0.01, QColor(253, 203, 241, 255)), QGradientStop(1, QColor(230, 222, 233, 255))); + case QGradient::WinterNeva: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(161, 196, 253, 255)), QGradientStop(1, QColor(194, 233, 251, 255))); + case QGradient::DustyGrass: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(212, 252, 121, 255)), QGradientStop(1, QColor(150, 230, 161, 255))); + case QGradient::TemptingAzure: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(132, 250, 176, 255)), QGradientStop(1, QColor(143, 211, 244, 255))); + case QGradient::HeavyRain: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(207, 217, 223, 255)), QGradientStop(1, QColor(226, 235, 240, 255))); + case QGradient::AmyCrisp: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(166, 192, 254, 255)), QGradientStop(1, QColor(246, 128, 132, 255))); + case QGradient::MeanFruit: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(252, 203, 144, 255)), QGradientStop(1, QColor(213, 126, 235, 255))); + case QGradient::DeepBlue: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(224, 195, 252, 255)), QGradientStop(1, QColor(142, 197, 252, 255))); + case QGradient::RipeMalinka: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(240, 147, 251, 255)), QGradientStop(1, QColor(245, 87, 108, 255))); + case QGradient::CloudyKnoxville: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(253, 251, 251, 255)), QGradientStop(1, QColor(235, 237, 238, 255))); + case QGradient::MalibuBeach: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(79, 172, 254, 255)), QGradientStop(1, QColor(0, 242, 254, 255))); + case QGradient::NewLife: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(67, 233, 123, 255)), QGradientStop(1, QColor(56, 249, 215, 255))); + case QGradient::TrueSunset: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(250, 112, 154, 255)), QGradientStop(1, QColor(254, 225, 64, 255))); + case QGradient::MorpheusDen: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(48, 207, 208, 255)), QGradientStop(1, QColor(51, 8, 103, 255))); + case QGradient::RareWind: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(168, 237, 234, 255)), QGradientStop(1, QColor(254, 214, 227, 255))); + case QGradient::NearMoon: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(94, 231, 223, 255)), QGradientStop(1, QColor(180, 144, 202, 255))); + case QGradient::WildApple: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(210, 153, 194, 255)), QGradientStop(1, QColor(254, 249, 215, 255))); + case QGradient::SaintPetersburg: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(245, 247, 250, 255)), QGradientStop(1, QColor(195, 207, 226, 255))); + case QGradient::PlumPlate: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(102, 126, 234, 255)), QGradientStop(1, QColor(118, 75, 162, 255))); + case QGradient::EverlastingSky: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(253, 252, 251, 255)), QGradientStop(1, QColor(226, 209, 195, 255))); + case QGradient::HappyFisher: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(137, 247, 254, 255)), QGradientStop(1, QColor(102, 166, 255, 255))); + case QGradient::Blessing: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(253, 219, 146, 255)), QGradientStop(1, QColor(209, 253, 255, 255))); + case QGradient::SharpeyeEagle: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(152, 144, 227, 255)), QGradientStop(1, QColor(177, 244, 207, 255))); + case QGradient::LadogaBottom: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(235, 192, 253, 255)), QGradientStop(1, QColor(217, 222, 216, 255))); + case QGradient::LemonGate: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(150, 251, 196, 255)), QGradientStop(1, QColor(249, 245, 134, 255))); + case QGradient::ItmeoBranding: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(42, 245, 152, 255)), QGradientStop(1, QColor(0, 158, 253, 255))); + case QGradient::ZeusMiracle: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(205, 156, 242, 255)), QGradientStop(1, QColor(246, 243, 255, 255))); + case QGradient::OldHat: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(228, 175, 203, 255)), QGradientStop(0, QColor(184, 203, 184, 255)), QGradientStop(0, QColor(184, 203, 184, 255)), QGradientStop(0.3, QColor(226, 197, 139, 255)), QGradientStop(0.64, QColor(194, 206, 156, 255)), QGradientStop(1, QColor(126, 219, 220, 255))); + case QGradient::StarWine: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(184, 203, 184, 255)), QGradientStop(0, QColor(184, 203, 184, 255)), QGradientStop(0, QColor(180, 101, 218, 255)), QGradientStop(0.33, QColor(207, 108, 201, 255)), QGradientStop(0.66, QColor(238, 96, 156, 255)), QGradientStop(1, QColor(238, 96, 156, 255))); + case QGradient::HappyAcid: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(55, 236, 186, 255)), QGradientStop(1, QColor(114, 175, 211, 255))); + case QGradient::AwesomePine: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(235, 187, 167, 255)), QGradientStop(1, QColor(207, 199, 248, 255))); + case QGradient::NewYork: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 241, 235, 255)), QGradientStop(1, QColor(172, 224, 249, 255))); + case QGradient::ShyRainbow: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(238, 162, 162, 255)), QGradientStop(0.19, QColor(187, 193, 191, 255)), QGradientStop(0.42, QColor(87, 198, 225, 255)), QGradientStop(0.79, QColor(180, 159, 218, 255)), QGradientStop(1, QColor(122, 197, 216, 255))); + case QGradient::MixedHopes: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(196, 113, 245, 255)), QGradientStop(1, QColor(250, 113, 205, 255))); + case QGradient::FlyHigh: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(72, 198, 239, 255)), QGradientStop(1, QColor(111, 134, 214, 255))); + case QGradient::StrongBliss: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(247, 140, 160, 255)), QGradientStop(0.19, QColor(249, 116, 143, 255)), QGradientStop(0.6, QColor(253, 134, 140, 255)), QGradientStop(1, QColor(254, 154, 139, 255))); + case QGradient::FreshMilk: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(254, 173, 166, 255)), QGradientStop(1, QColor(245, 239, 239, 255))); + case QGradient::SnowAgain: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(230, 233, 240, 255)), QGradientStop(1, QColor(238, 241, 245, 255))); + case QGradient::FebruaryInk: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(172, 203, 238, 255)), QGradientStop(1, QColor(231, 240, 253, 255))); + case QGradient::KindSteel: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(233, 222, 250, 255)), QGradientStop(1, QColor(251, 252, 219, 255))); + case QGradient::SoftGrass: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(193, 223, 196, 255)), QGradientStop(1, QColor(222, 236, 221, 255))); + case QGradient::GrownEarly: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(11, 163, 96, 255)), QGradientStop(1, QColor(60, 186, 146, 255))); + case QGradient::SharpBlues: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(0, 198, 251, 255)), QGradientStop(1, QColor(0, 91, 234, 255))); + case QGradient::ShadyWater: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(116, 235, 213, 255)), QGradientStop(1, QColor(159, 172, 230, 255))); + case QGradient::DirtyBeauty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(106, 133, 182, 255)), QGradientStop(1, QColor(186, 200, 224, 255))); + case QGradient::GreatWhale: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(163, 189, 237, 255)), QGradientStop(1, QColor(105, 145, 199, 255))); + case QGradient::TeenNotebook: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(151, 149, 240, 255)), QGradientStop(1, QColor(251, 200, 212, 255))); + case QGradient::PoliteRumors: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(167, 166, 203, 255)), QGradientStop(0.52, QColor(137, 137, 186, 255)), QGradientStop(1, QColor(137, 137, 186, 255))); + case QGradient::SweetPeriod: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(63, 81, 177, 255)), QGradientStop(0.13, QColor(90, 85, 174, 255)), QGradientStop(0.25, QColor(123, 95, 172, 255)), QGradientStop(0.38, QColor(143, 106, 174, 255)), QGradientStop(0.5, QColor(168, 106, 164, 255)), QGradientStop(0.62, QColor(204, 107, 142, 255)), QGradientStop(0.75, QColor(241, 130, 113, 255)), QGradientStop(0.87, QColor(243, 164, 105, 255)), QGradientStop(1, QColor(247, 201, 120, 255))); + case QGradient::WideMatrix: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(252, 197, 228, 255)), QGradientStop(0.15, QColor(253, 163, 75, 255)), QGradientStop(0.35, QColor(255, 120, 130, 255)), QGradientStop(0.52, QColor(200, 105, 158, 255)), QGradientStop(0.71, QColor(112, 70, 170, 255)), QGradientStop(0.87, QColor(12, 29, 184, 255)), QGradientStop(1, QColor(2, 15, 117, 255))); + case QGradient::SoftCherish: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(219, 220, 215, 255)), QGradientStop(0.24, QColor(221, 220, 215, 255)), QGradientStop(0.3, QColor(226, 201, 204, 255)), QGradientStop(0.46, QColor(231, 98, 125, 255)), QGradientStop(0.59, QColor(184, 35, 90, 255)), QGradientStop(0.71, QColor(128, 19, 87, 255)), QGradientStop(0.84, QColor(61, 22, 53, 255)), QGradientStop(1, QColor(28, 26, 39, 255))); + case QGradient::RedSalvation: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(244, 59, 71, 255)), QGradientStop(1, QColor(69, 58, 148, 255))); + case QGradient::BurningSpring: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(79, 181, 118, 255)), QGradientStop(0.3, QColor(68, 196, 137, 255)), QGradientStop(0.46, QColor(40, 169, 174, 255)), QGradientStop(0.59, QColor(40, 162, 183, 255)), QGradientStop(0.71, QColor(76, 119, 136, 255)), QGradientStop(0.86, QColor(108, 79, 99, 255)), QGradientStop(1, QColor(67, 44, 57, 255))); + case QGradient::NightParty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(2, 80, 197, 255)), QGradientStop(1, QColor(212, 63, 141, 255))); + case QGradient::SkyGlider: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(136, 211, 206, 255)), QGradientStop(1, QColor(110, 69, 226, 255))); + case QGradient::HeavenPeach: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(217, 175, 217, 255)), QGradientStop(1, QColor(151, 217, 225, 255))); + case QGradient::PurpleDivision: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(112, 40, 228, 255)), QGradientStop(1, QColor(229, 178, 202, 255))); + case QGradient::AquaSplash: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(19, 84, 122, 255)), QGradientStop(1, QColor(128, 208, 199, 255))); + case QGradient::SpikyNaga: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(80, 82, 133, 255)), QGradientStop(0.12, QColor(88, 94, 146, 255)), QGradientStop(0.25, QColor(101, 104, 159, 255)), QGradientStop(0.37, QColor(116, 116, 176, 255)), QGradientStop(0.5, QColor(126, 126, 187, 255)), QGradientStop(0.62, QColor(131, 137, 199, 255)), QGradientStop(0.75, QColor(151, 149, 212, 255)), QGradientStop(0.87, QColor(162, 161, 220, 255)), QGradientStop(1, QColor(181, 174, 228, 255))); + case QGradient::LoveKiss: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 8, 68, 255)), QGradientStop(1, QColor(255, 177, 153, 255))); + case QGradient::CleanMirror: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(147, 165, 207, 255)), QGradientStop(1, QColor(228, 239, 233, 255))); + case QGradient::PremiumDark: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(67, 67, 67, 255)), QGradientStop(1, QColor(0, 0, 0, 255))); + case QGradient::ColdEvening: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(12, 52, 131, 255)), QGradientStop(1, QColor(162, 182, 223, 255)), QGradientStop(1, QColor(107, 140, 206, 255)), QGradientStop(1, QColor(162, 182, 223, 255))); + case QGradient::CochitiLake: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(147, 165, 207, 255)), QGradientStop(1, QColor(228, 239, 233, 255))); + case QGradient::SummerGames: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(146, 254, 157, 255)), QGradientStop(1, QColor(0, 201, 255, 255))); + case QGradient::PassionateBed: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 117, 140, 255)), QGradientStop(1, QColor(255, 126, 179, 255))); + case QGradient::MountainRock: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(134, 143, 150, 255)), QGradientStop(1, QColor(89, 97, 100, 255))); + case QGradient::DesertHump: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(199, 144, 129, 255)), QGradientStop(1, QColor(223, 165, 121, 255))); + case QGradient::JungleDay: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(139, 170, 170, 255)), QGradientStop(1, QColor(174, 139, 156, 255))); + case QGradient::PhoenixStart: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(248, 54, 0, 255)), QGradientStop(1, QColor(249, 212, 35, 255))); + case QGradient::OctoberSilence: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(183, 33, 255, 255)), QGradientStop(1, QColor(33, 212, 253, 255))); + case QGradient::FarawayRiver: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(110, 69, 226, 255)), QGradientStop(1, QColor(136, 211, 206, 255))); + case QGradient::AlchemistLab: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(213, 88, 200, 255)), QGradientStop(1, QColor(36, 210, 146, 255))); + case QGradient::OverSun: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(171, 236, 214, 255)), QGradientStop(1, QColor(251, 237, 150, 255))); + case QGradient::PremiumWhite: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(213, 212, 208, 255)), QGradientStop(0.01, QColor(213, 212, 208, 255)), QGradientStop(0.31, QColor(238, 238, 236, 255)), QGradientStop(0.75, QColor(239, 238, 236, 255)), QGradientStop(1, QColor(233, 233, 231, 255))); + case QGradient::MarsParty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(95, 114, 189, 255)), QGradientStop(1, QColor(155, 35, 234, 255))); + case QGradient::EternalConstance: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(9, 32, 63, 255)), QGradientStop(1, QColor(83, 120, 149, 255))); + case QGradient::JapanBlush: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(221, 214, 243, 255)), QGradientStop(1, QColor(250, 172, 168, 255)), QGradientStop(1, QColor(250, 172, 168, 255))); + case QGradient::SmilingRain: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(220, 176, 237, 255)), QGradientStop(1, QColor(153, 201, 156, 255))); + case QGradient::CloudyApple: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(243, 231, 233, 255)), QGradientStop(0.99, QColor(227, 238, 255, 255)), QGradientStop(1, QColor(227, 238, 255, 255))); + case QGradient::BigMango: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(199, 29, 111, 255)), QGradientStop(1, QColor(208, 150, 147, 255))); + case QGradient::HealthyWater: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(150, 222, 218, 255)), QGradientStop(1, QColor(80, 201, 195, 255))); + case QGradient::AmourAmour: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(247, 112, 98, 255)), QGradientStop(1, QColor(254, 81, 150, 255))); + case QGradient::RiskyConcrete: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(196, 197, 199, 255)), QGradientStop(0.52, QColor(220, 221, 223, 255)), QGradientStop(1, QColor(235, 235, 235, 255))); + case QGradient::StrongStick: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(168, 202, 186, 255)), QGradientStop(1, QColor(93, 65, 87, 255))); + case QGradient::ViciousStance: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(41, 50, 60, 255)), QGradientStop(1, QColor(72, 85, 99, 255))); + case QGradient::PaloAlto: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(22, 160, 133, 255)), QGradientStop(1, QColor(244, 208, 63, 255))); + case QGradient::HappyMemories: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 88, 88, 255)), QGradientStop(1, QColor(240, 152, 25, 255))); + case QGradient::MidnightBloom: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(43, 88, 118, 255)), QGradientStop(1, QColor(78, 67, 118, 255))); + case QGradient::Crystalline: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(0, 205, 172, 255)), QGradientStop(1, QColor(141, 218, 213, 255))); + case QGradient::PartyBliss: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(68, 129, 235, 255)), QGradientStop(1, QColor(4, 190, 254, 255))); + case QGradient::ConfidentCloud: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(218, 212, 236, 255)), QGradientStop(0.01, QColor(218, 212, 236, 255)), QGradientStop(1, QColor(243, 231, 233, 255))); + case QGradient::LeCocktail: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(135, 77, 162, 255)), QGradientStop(1, QColor(196, 58, 48, 255))); + case QGradient::RiverCity: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(68, 129, 235, 255)), QGradientStop(1, QColor(4, 190, 254, 255))); + case QGradient::FrozenBerry: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(232, 25, 139, 255)), QGradientStop(1, QColor(199, 234, 253, 255))); + case QGradient::ChildCare: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(247, 148, 164, 255)), QGradientStop(1, QColor(253, 214, 189, 255))); + case QGradient::FlyingLemon: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(100, 179, 244, 255)), QGradientStop(1, QColor(194, 229, 156, 255))); + case QGradient::NewRetrowave: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(59, 65, 197, 255)), QGradientStop(0.49, QColor(169, 129, 187, 255)), QGradientStop(1, QColor(255, 200, 169, 255))); + case QGradient::HiddenJaguar: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(15, 216, 80, 255)), QGradientStop(1, QColor(249, 240, 71, 255))); + case QGradient::AboveTheSky: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(211, 211, 211, 255)), QGradientStop(0.01, QColor(211, 211, 211, 255)), QGradientStop(0.26, QColor(224, 224, 224, 255)), QGradientStop(0.48, QColor(239, 239, 239, 255)), QGradientStop(0.75, QColor(217, 217, 217, 255)), QGradientStop(1, QColor(188, 188, 188, 255))); + case QGradient::Nega: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(238, 156, 167, 255)), QGradientStop(1, QColor(255, 221, 225, 255))); + case QGradient::DenseWater: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(58, 181, 176, 255)), QGradientStop(0.31, QColor(61, 153, 190, 255)), QGradientStop(1, QColor(86, 49, 122, 255))); + case QGradient::Seashore: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(32, 156, 255, 255)), QGradientStop(1, QColor(104, 224, 207, 255))); + case QGradient::MarbleWall: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(189, 194, 232, 255)), QGradientStop(0.01, QColor(189, 194, 232, 255)), QGradientStop(1, QColor(230, 222, 233, 255))); + case QGradient::CheerfulCaramel: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(230, 185, 128, 255)), QGradientStop(1, QColor(234, 205, 163, 255))); + case QGradient::NightSky: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(30, 60, 114, 255)), QGradientStop(0.01, QColor(30, 60, 114, 255)), QGradientStop(1, QColor(42, 82, 152, 255))); + case QGradient::MagicLake: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(213, 222, 231, 255)), QGradientStop(0, QColor(255, 175, 189, 255)), QGradientStop(1, QColor(201, 255, 191, 255))); + case QGradient::YoungGrass: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(155, 225, 93, 255)), QGradientStop(1, QColor(0, 227, 174, 255))); + case QGradient::ColorfulPeach: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(237, 110, 160, 255)), QGradientStop(1, QColor(236, 140, 105, 255))); + case QGradient::GentleCare: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 195, 160, 255)), QGradientStop(1, QColor(255, 175, 189, 255))); + case QGradient::PlumBath: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(204, 32, 142, 255)), QGradientStop(1, QColor(103, 19, 210, 255))); + case QGradient::HappyUnicorn: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(179, 255, 171, 255)), QGradientStop(1, QColor(18, 255, 247, 255))); + case QGradient::AfricanField: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(101, 189, 96, 255)), QGradientStop(0.25, QColor(90, 193, 168, 255)), QGradientStop(0.5, QColor(62, 198, 237, 255)), QGradientStop(0.75, QColor(183, 221, 183, 255)), QGradientStop(1, QColor(254, 243, 129, 255))); + case QGradient::SolidStone: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(36, 57, 73, 255)), QGradientStop(1, QColor(81, 127, 164, 255))); + case QGradient::OrangeJuice: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(252, 96, 118, 255)), QGradientStop(1, QColor(255, 154, 68, 255))); + case QGradient::GlassWater: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(223, 233, 243, 255)), QGradientStop(1, QColor(255, 255, 255, 255))); + case QGradient::NorthMiracle: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(0, 219, 222, 255)), QGradientStop(1, QColor(252, 0, 255, 255))); + case QGradient::FruitBlend: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(249, 212, 35, 255)), QGradientStop(1, QColor(255, 78, 80, 255))); + case QGradient::MillenniumPine: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(80, 204, 127, 255)), QGradientStop(1, QColor(245, 209, 0, 255))); + case QGradient::HighFlight: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(10, 207, 254, 255)), QGradientStop(1, QColor(73, 90, 255, 255))); + case QGradient::MoleHall: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(97, 97, 97, 255)), QGradientStop(1, QColor(155, 197, 195, 255))); + case QGradient::SpaceShift: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(61, 51, 147, 255)), QGradientStop(0.37, QColor(43, 118, 185, 255)), QGradientStop(0.65, QColor(44, 172, 209, 255)), QGradientStop(1, QColor(53, 235, 147, 255))); + case QGradient::ForestInei: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(223, 137, 181, 255)), QGradientStop(1, QColor(191, 217, 254, 255))); + case QGradient::RoyalGarden: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(237, 110, 160, 255)), QGradientStop(1, QColor(236, 140, 105, 255))); + case QGradient::RichMetal: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(215, 210, 204, 255)), QGradientStop(1, QColor(48, 67, 82, 255))); + case QGradient::JuicyCake: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(225, 79, 173, 255)), QGradientStop(1, QColor(249, 212, 35, 255))); + case QGradient::SmartIndigo: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(178, 36, 239, 255)), QGradientStop(1, QColor(117, 121, 255, 255))); + case QGradient::SandStrike: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(193, 193, 97, 255)), QGradientStop(0, QColor(193, 193, 97, 255)), QGradientStop(1, QColor(212, 212, 177, 255))); + case QGradient::NorseBeauty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(236, 119, 171, 255)), QGradientStop(1, QColor(120, 115, 245, 255))); + case QGradient::AquaGuidance: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(0, 122, 223, 255)), QGradientStop(1, QColor(0, 236, 188, 255))); + case QGradient::SunVeggie: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(32, 226, 215, 255)), QGradientStop(1, QColor(249, 254, 165, 255))); + case QGradient::SeaLord: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(44, 216, 213, 255)), QGradientStop(0.56, QColor(197, 193, 255, 255)), QGradientStop(1, QColor(255, 186, 195, 255))); + case QGradient::BlackSea: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(44, 216, 213, 255)), QGradientStop(0.48, QColor(107, 141, 214, 255)), QGradientStop(1, QColor(142, 55, 215, 255))); + case QGradient::GrassShampoo: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(223, 255, 205, 255)), QGradientStop(0.48, QColor(144, 249, 196, 255)), QGradientStop(1, QColor(57, 243, 187, 255))); + case QGradient::LandingAircraft: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(93, 159, 255, 255)), QGradientStop(0.48, QColor(184, 220, 255, 255)), QGradientStop(1, QColor(107, 187, 255, 255))); + case QGradient::WitchDance: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(168, 191, 255, 255)), QGradientStop(1, QColor(136, 77, 128, 255))); + case QGradient::SleeplessNight: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(82, 113, 196, 255)), QGradientStop(0.48, QColor(177, 159, 255, 255)), QGradientStop(1, QColor(236, 161, 254, 255))); + case QGradient::AngelCare: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 226, 159, 255)), QGradientStop(0.48, QColor(255, 169, 159, 255)), QGradientStop(1, QColor(255, 113, 154, 255))); + case QGradient::CrystalRiver: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(34, 225, 255, 255)), QGradientStop(0.48, QColor(29, 143, 225, 255)), QGradientStop(1, QColor(98, 94, 177, 255))); + case QGradient::SoftLipstick: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(182, 206, 232, 255)), QGradientStop(1, QColor(245, 120, 220, 255))); + case QGradient::SaltMountain: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 254, 255, 255)), QGradientStop(1, QColor(215, 255, 254, 255))); + case QGradient::PerfectWhite: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(227, 253, 245, 255)), QGradientStop(1, QColor(255, 230, 250, 255))); + case QGradient::FreshOasis: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(125, 226, 252, 255)), QGradientStop(1, QColor(185, 182, 229, 255))); + case QGradient::StrictNovember: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(203, 186, 204, 255)), QGradientStop(1, QColor(37, 128, 179, 255))); + case QGradient::MorningSalad: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(183, 248, 219, 255)), QGradientStop(1, QColor(80, 167, 194, 255))); + case QGradient::DeepRelief: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(112, 133, 182, 255)), QGradientStop(0.5, QColor(135, 167, 217, 255)), QGradientStop(1, QColor(222, 243, 248, 255))); + case QGradient::SeaStrike: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(119, 255, 210, 255)), QGradientStop(0.48, QColor(98, 151, 219, 255)), QGradientStop(1, QColor(30, 236, 255, 255))); + case QGradient::NightCall: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(172, 50, 228, 255)), QGradientStop(0.48, QColor(121, 24, 242, 255)), QGradientStop(1, QColor(72, 1, 255, 255))); + case QGradient::SupremeSky: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(212, 255, 236, 255)), QGradientStop(0.48, QColor(87, 242, 204, 255)), QGradientStop(1, QColor(69, 150, 251, 255))); + case QGradient::LightBlue: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(158, 251, 211, 255)), QGradientStop(0.48, QColor(87, 233, 242, 255)), QGradientStop(1, QColor(69, 212, 251, 255))); + case QGradient::MindCrawl: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(71, 59, 123, 255)), QGradientStop(0.51, QColor(53, 132, 167, 255)), QGradientStop(1, QColor(48, 210, 190, 255))); + case QGradient::LilyMeadow: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(101, 55, 155, 255)), QGradientStop(0.53, QColor(136, 106, 234, 255)), QGradientStop(1, QColor(100, 87, 198, 255))); + case QGradient::SugarLollipop: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(164, 69, 178, 255)), QGradientStop(0.52, QColor(212, 24, 114, 255)), QGradientStop(1, QColor(255, 0, 102, 255))); + case QGradient::SweetDessert: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(119, 66, 178, 255)), QGradientStop(0.52, QColor(241, 128, 255, 255)), QGradientStop(1, QColor(253, 139, 217, 255))); + case QGradient::MagicRay: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 60, 172, 255)), QGradientStop(0.52, QColor(86, 43, 124, 255)), QGradientStop(1, QColor(43, 134, 197, 255))); + case QGradient::TeenParty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 5, 124, 255)), QGradientStop(0.5, QColor(141, 11, 147, 255)), QGradientStop(1, QColor(50, 21, 117, 255))); + case QGradient::FrozenHeat: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 5, 124, 255)), QGradientStop(0.48, QColor(124, 100, 213, 255)), QGradientStop(1, QColor(76, 195, 255, 255))); + case QGradient::GagarinView: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(105, 234, 203, 255)), QGradientStop(0.48, QColor(234, 204, 248, 255)), QGradientStop(1, QColor(102, 84, 241, 255))); + case QGradient::FabledSunset: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(35, 21, 87, 255)), QGradientStop(0.29, QColor(68, 16, 122, 255)), QGradientStop(0.67, QColor(255, 19, 97, 255)), QGradientStop(1, QColor(255, 248, 0, 255))); + case QGradient::PerfectBlue: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(61, 78, 129, 255)), QGradientStop(0.48, QColor(87, 83, 201, 255)), QGradientStop(1, QColor(110, 127, 243, 255))); + case QGradient::NumPresets: + Q_UNREACHABLE(); + } + Q_UNREACHABLE(); + return {}; +} + +static Q_CONSTEXPR QGradient::QGradientData qt_preset_gradient_data[] = { + { { 0, 1, 1, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { 0.5, 1, 0.5, 0 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 0, 0 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 0, 0.5, 1 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0, 0, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.341506, 1.09151, 0.658494, -0.0915064 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 1.09151, 0.841506, -0.0915064, 0.158494 } }, + { { 1.09151, 0.841506, -0.0915064, 0.158494 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0, 0, 0, 0 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, +}; + +static void *qt_preset_gradient_dummy() +{ + union {void *p; uint i;}; + p = 0; + i |= uint(QGradient::ObjectMode); + return p; +} diff --git a/src/gui/painting/webgradients.css b/src/gui/painting/webgradients.css deleted file mode 100644 index 870866bb46..0000000000 --- a/src/gui/painting/webgradients.css +++ /dev/null @@ -1,909 +0,0 @@ -/*001 Warm Flame*/ -.warm_flame{ - background-image: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%); -} - -/*002 Night Fade*/ -.night_fade{ - background-image: linear-gradient(to top, #a18cd1 0%, #fbc2eb 100%); -} - -/*003 Spring Warmth*/ -.spring_warmth{ - background-image: linear-gradient(to top, #fad0c4 0%, #fad0c4 1%, #ffd1ff 100%); -} - -/*004 Juicy Peach*/ -.juicy_peach{ - background-image: linear-gradient(to right, #ffecd2 0%, #fcb69f 100%); -} - -/*005 Young Passion*/ -.young_passion{ - background-image: linear-gradient(to right, #ff8177 0%, #ff867a 0%, #ff8c7f 21%, #f99185 52%, #cf556c 78%, #b12a5b 100%); -} - -/*006 Lady Lips*/ -.lady_lips{ - background-image: linear-gradient(to top, #ff9a9e 0%, #fecfef 99%, #fecfef 100%); -} - -/*007 Sunny Morning*/ -.sunny_morning{ - background-image: linear-gradient(120deg, #f6d365 0%, #fda085 100%); -} - -/*008 Rainy Ashville*/ -.rainy_ashville{ - background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%); -} - -/*009 Frozen Dreams*/ -.frozen_dreams{ - background-image: linear-gradient(to top, #fdcbf1 0%, #fdcbf1 1%, #e6dee9 100%); -} - -/*010 Winter Neva*/ -.winter_neva{ - background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%); -} - -/*011 Dusty Grass*/ -.dusty_grass{ - background-image: linear-gradient(120deg, #d4fc79 0%, #96e6a1 100%); -} - -/*012 Tempting Azure*/ -.tempting_azure{ - background-image: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%); -} - -/*013 Heavy Rain*/ -.heavy_rain{ - background-image: linear-gradient(to top, #cfd9df 0%, #e2ebf0 100%); -} - -/*014 Amy Crisp*/ -.amy_crisp{ - background-image: linear-gradient(120deg, #a6c0fe 0%, #f68084 100%); -} - -/*015 Mean Fruit*/ -.mean_fruit{ - background-image: linear-gradient(120deg, #fccb90 0%, #d57eeb 100%); -} - -/*016 Deep Blue*/ -.deep_blue{ - background-image: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%); -} - -/*017 Ripe Malinka*/ -.ripe_malinka{ - background-image: linear-gradient(120deg, #f093fb 0%, #f5576c 100%); -} - -/*018 Cloudy Knoxville*/ -.cloudy_knoxville{ - background-image: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%); -} - -/*019 Malibu Beach*/ -.malibu_beach{ - background-image: linear-gradient(to right, #4facfe 0%, #00f2fe 100%); -} - -/*020 New Life*/ -.new_life{ - background-image: linear-gradient(to right, #43e97b 0%, #38f9d7 100%); -} - -/*021 True Sunset*/ -.true_sunset{ - background-image: linear-gradient(to right, #fa709a 0%, #fee140 100%); -} - -/*022 Morpheus Den*/ -.morpheus_den{ - background-image: linear-gradient(to top, #30cfd0 0%, #330867 100%); -} - -/*023 Rare Wind*/ -.rare_wind{ - background-image: linear-gradient(to top, #a8edea 0%, #fed6e3 100%); -} - -/*024 Near Moon*/ -.near_moon{ - background-image: linear-gradient(to top, #5ee7df 0%, #b490ca 100%); -} - -/*025 Wild Apple*/ -.wild_apple{ - background-image: linear-gradient(to top, #d299c2 0%, #fef9d7 100%); -} - -/*026 Saint Petersburg*/ -.saint_petersburg{ - background-image: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); -} - -/*027 Arielle's Smile*/ -.arielles_smile{ - background-image: radial-gradient(circle 248px at center, #16d9e3 0%, #30c7ec 47%, #46aef7 100%); -} - -/*028 Plum Plate*/ -.plum_plate{ - background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%); -} - -/*029 Everlasting Sky*/ -.everlasting_sky{ - background-image: linear-gradient(135deg, #fdfcfb 0%, #e2d1c3 100%); -} - -/*030 Happy Fisher*/ -.happy_fisher{ - background-image: linear-gradient(120deg, #89f7fe 0%, #66a6ff 100%); -} - -/*031 Blessing*/ -.blessing{ - background-image: linear-gradient(to top, #fddb92 0%, #d1fdff 100%); -} - -/*032 Sharpeye Eagle*/ -.sharpeye_eagle{ - background-image: linear-gradient(to top, #9890e3 0%, #b1f4cf 100%); -} - -/*033 Ladoga Bottom*/ -.ladoga_bottom{ - background-image: linear-gradient(to top, #ebc0fd 0%, #d9ded8 100%); -} - -/*034 Lemon Gate*/ -.lemon_gate{ - background-image: linear-gradient(to top, #96fbc4 0%, #f9f586 100%); -} - -/*035 Itmeo Branding*/ -.itmeo_branding{ - background-image: linear-gradient(180deg, #2af598 0%, #009efd 100%); -} - -/*036 Zeus Miracle*/ -.zeus_miracle{ - background-image: linear-gradient(to top, #cd9cf2 0%, #f6f3ff 100%); -} - -/*037 Old Hat*/ -.old_hat{ - background-image: linear-gradient(to right, #e4afcb 0%, #b8cbb8 0%, #b8cbb8 0%, #e2c58b 30%, #c2ce9c 64%, #7edbdc 100%); -} - -/*038 Star Wine*/ -.star_wine{ - background-image: linear-gradient(to right, #b8cbb8 0%, #b8cbb8 0%, #b465da 0%, #cf6cc9 33%, #ee609c 66%, #ee609c 100%); -} - -/*039 Deep Blue*/ -.deep_blue{ - background-image: linear-gradient(to right, #6a11cb 0%, #2575fc 100%); -} - -/*040 Coup de Grace*/ -.coup_de_grace{ - background: #DCD9D4 linear-gradient(to bottom, rgba(255, 255, 255, 0.50) 0%, rgba(0, 0, 0, 0.50) 100%), radial-gradient(at 50% 0%, rgba(255, 255, 255, 0.10) 0%, rgba(0, 0, 0, 0.50) 50%); - background-blend-mode: soft-light,screen; -} - -/*041 Happy Acid*/ -.happy_acid{ - background-image: linear-gradient(to top, #37ecba 0%, #72afd3 100%); -} - -/*042 Awesome Pine*/ -.awesome_pine{ - background-image: linear-gradient(to top, #ebbba7 0%, #cfc7f8 100%); -} - -/*043 New York*/ -.new_york{ - background-image: linear-gradient(to top, #fff1eb 0%, #ace0f9 100%); -} - -/*044 Shy Rainbow*/ -.shy_rainbow{ - background-image: linear-gradient(to right, #eea2a2 0%, #bbc1bf 19%, #57c6e1 42%, #b49fda 79%, #7ac5d8 100%); -} - -/*045 Loon Crest*/ -.loon_crest{ - background: linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, rgba(0,0,0,0.15) 100%), radial-gradient(at top center, rgba(255,255,255,0.40) 0%, rgba(0,0,0,0.40) 120%) #989898; - background-blend-mode: multiply,multiply; -} - -/*046 Mixed Hopes*/ -.mixed_hopes{ - background-image: linear-gradient(to top, #c471f5 0%, #fa71cd 100%); -} - -/*047 Fly High*/ -.fly_high{ - background-image: linear-gradient(to top, #48c6ef 0%, #6f86d6 100%); -} - -/*048 Strong Bliss*/ -.strong_bliss{ - background-image: linear-gradient(to right, #f78ca0 0%, #f9748f 19%, #fd868c 60%, #fe9a8b 100%); -} - -/*049 Fresh Milk*/ -.fresh_milk{ - background-image: linear-gradient(to top, #feada6 0%, #f5efef 100%); -} - -/*050 Snow Again*/ -.snow_again{ - background-image: linear-gradient(to top, #e6e9f0 0%, #eef1f5 100%); -} - -/*051 February Ink*/ -.february_ink{ - background-image: linear-gradient(to top, #accbee 0%, #e7f0fd 100%); -} - -/*052 Kind Steel*/ -.kind_steel{ - background-image: linear-gradient(-20deg, #e9defa 0%, #fbfcdb 100%); -} - -/*053 Soft Grass*/ -.soft_grass{ - background-image: linear-gradient(to top, #c1dfc4 0%, #deecdd 100%); -} - -/*054 Grown Early*/ -.grown_early{ - background-image: linear-gradient(to top, #0ba360 0%, #3cba92 100%); -} - -/*055 Sharp Blues*/ -.sharp_blues{ - background-image: linear-gradient(to top, #00c6fb 0%, #005bea 100%); -} - -/*056 Shady Water*/ -.shady_water{ - background-image: linear-gradient(to right, #74ebd5 0%, #9face6 100%); -} - -/*057 Dirty Beauty*/ -.dirty_beauty{ - background-image: linear-gradient(to top, #6a85b6 0%, #bac8e0 100%); -} - -/*058 Great Whale*/ -.great_whale{ - background-image: linear-gradient(to top, #a3bded 0%, #6991c7 100%); -} - -/*059 Teen Notebook*/ -.teen_notebook{ - background-image: linear-gradient(to top, #9795f0 0%, #fbc8d4 100%); -} - -/*060 Polite Rumors*/ -.polite_rumors{ - background-image: linear-gradient(to top, #a7a6cb 0%, #8989ba 52%, #8989ba 100%); -} - -/*061 Sweet Period*/ -.sweet_period{ - background-image: linear-gradient(to top, #3f51b1 0%, #5a55ae 13%, #7b5fac 25%, #8f6aae 38%, #a86aa4 50%, #cc6b8e 62%, #f18271 75%, #f3a469 87%, #f7c978 100%); -} - -/*062 Wide Matrix*/ -.wide_matrix{ - background-image: linear-gradient(to top, #fcc5e4 0%, #fda34b 15%, #ff7882 35%, #c8699e 52%, #7046aa 71%, #0c1db8 87%, #020f75 100%); -} - -/*063 Soft Cherish*/ -.soft_cherish{ - background-image: linear-gradient(to top, #dbdcd7 0%, #dddcd7 24%, #e2c9cc 30%, #e7627d 46%, #b8235a 59%, #801357 71%, #3d1635 84%, #1c1a27 100%); -} - -/*064 Red Salvation*/ -.red_salvation{ - background-image: linear-gradient(to top, #f43b47 0%, #453a94 100%); -} - -/*065 Burning Spring*/ -.burning_spring{ - background-image: linear-gradient(to top, #4fb576 0%, #44c489 30%, #28a9ae 46%, #28a2b7 59%, #4c7788 71%, #6c4f63 86%, #432c39 100%); -} - -/*066 Night Party*/ -.night_party{ - background-image: linear-gradient(to top, #0250c5 0%, #d43f8d 100%); -} - -/*067 Sky Glider*/ -.sky_glider{ - background-image: linear-gradient(to top, #88d3ce 0%, #6e45e2 100%); -} - -/*068 Heaven Peach*/ -.heaven_peach{ - background-image: linear-gradient(to top, #d9afd9 0%, #97d9e1 100%); -} - -/*069 Purple Division*/ -.purple_division{ - background-image: linear-gradient(to top, #7028e4 0%, #e5b2ca 100%); -} - -/*070 Aqua Splash*/ -.aqua_splash{ - background-image: linear-gradient(15deg, #13547a 0%, #80d0c7 100%); -} - -/*071 Above Clouds*/ -.above_clouds{ - background-image: linear-gradient(to left, #BDBBBE 0%, #9D9EA3 100%), radial-gradient(88% 271%, rgba(255, 255, 255, 0.25) 0%, rgba(254, 254, 254, 0.25) 1%, rgba(0, 0, 0, 0.25) 100%), radial-gradient(50% 100%, rgba(255, 255, 255, 0.30) 0%, rgba(0, 0, 0, 0.30) 100%); - background-blend-mode: normal, lighten, soft-light; -} - -/*072 Spiky Naga*/ -.spiky_naga{ - background-image: linear-gradient(to top, #505285 0%, #585e92 12%, #65689f 25%, #7474b0 37%, #7e7ebb 50%, #8389c7 62%, #9795d4 75%, #a2a1dc 87%, #b5aee4 100%); -} - -/*073 Love Kiss*/ -.love_kiss{ - background-image: linear-gradient(to top, #ff0844 0%, #ffb199 100%); -} - -/*074 Sharp Glass*/ -.sharp_glass{ - background: #C9CCD3 linear-gradient(-180deg, rgba(255, 255, 255, 0.50) 0%, rgba(0, 0, 0, 0.50) 100%); - background-blend-mode: lighten; -} - -/*075 Clean Mirror*/ -.clean_mirror{ - background-image: linear-gradient(45deg, #93a5cf 0%, #e4efe9 100%); -} - -/*076 Premium Dark*/ -.premium_dark{ - background-image: linear-gradient(to right, #434343 0%, black 100%); -} - -/*077 Cold Evening*/ -.cold_evening{ - background-image: linear-gradient(to top, #0c3483 0%, #a2b6df 100%, #6b8cce 100%, #a2b6df 100%); -} - -/*078 Cochiti Lake*/ -.cochiti_lake{ - background-image: linear-gradient(45deg, #93a5cf 0%, #e4efe9 100%); -} - -/*079 Summer Games*/ -.summer_games{ - background-image: linear-gradient(to right, #92fe9d 0%, #00c9ff 100%); -} - -/*080 Passionate Bed*/ -.passionate_bed{ - background-image: linear-gradient(to right, #ff758c 0%, #ff7eb3 100%); -} - -/*081 Mountain Rock*/ -.mountain_rock{ - background-image: linear-gradient(to right, #868f96 0%, #596164 100%); -} - -/*082 Desert Hump*/ -.desert_hump{ - background-image: linear-gradient(to top, #c79081 0%, #dfa579 100%); -} - -/*083 Jungle Day*/ -.jungle_day{ - background-image: linear-gradient(45deg, #8baaaa 0%, #ae8b9c 100%); -} - -/*084 Phoenix Start*/ -.phoenix_start{ - background-image: linear-gradient(to right, #f83600 0%, #f9d423 100%); -} - -/*085 October Silence*/ -.october_silence{ - background-image: linear-gradient(-20deg, #b721ff 0%, #21d4fd 100%); -} - -/*086 Faraway River*/ -.faraway_river{ - background-image: linear-gradient(-20deg, #6e45e2 0%, #88d3ce 100%); -} - -/*087 Alchemist Lab*/ -.alchemist_lab{ - background-image: linear-gradient(-20deg, #d558c8 0%, #24d292 100%); -} - -/*088 Over Sun*/ -.over_sun{ - background-image: linear-gradient(60deg, #abecd6 0%, #fbed96 100%); -} - -/*089 Premium White*/ -.premium_white{ - background-image: linear-gradient(to top, #d5d4d0 0%, #d5d4d0 1%, #eeeeec 31%, #efeeec 75%, #e9e9e7 100%); -} - -/*090 Mars Party*/ -.mars_party{ - background-image: linear-gradient(to top, #5f72bd 0%, #9b23ea 100%); -} - -/*091 Eternal Constance*/ -.eternal_constance{ - background-image: linear-gradient(to top, #09203f 0%, #537895 100%); -} - -/*092 Japan Blush*/ -.japan_blush{ - background-image: linear-gradient(-20deg, #ddd6f3 0%, #faaca8 100%, #faaca8 100%); -} - -/*093 Smiling Rain*/ -.smiling_rain{ - background-image: linear-gradient(-20deg, #dcb0ed 0%, #99c99c 100%); -} - -/*094 Cloudy Apple*/ -.cloudy_apple{ - background-image: linear-gradient(to top, #f3e7e9 0%, #e3eeff 99%, #e3eeff 100%); -} - -/*095 Big Mango*/ -.big_mango{ - background-image: linear-gradient(to top, #c71d6f 0%, #d09693 100%); -} - -/*096 Healthy Water*/ -.healthy_water{ - background-image: linear-gradient(60deg, #96deda 0%, #50c9c3 100%); -} - -/*097 Amour Amour*/ -.amour_amour{ - background-image: linear-gradient(to top, #f77062 0%, #fe5196 100%); -} - -/*098 Risky Concrete*/ -.risky_concrete{ - background-image: linear-gradient(to top, #c4c5c7 0%, #dcdddf 52%, #ebebeb 100%); -} - -/*099 Strong Stick*/ -.strong_stick{ - background-image: linear-gradient(to right, #a8caba 0%, #5d4157 100%); -} - -/*100 Vicious Stance*/ -.vicious_stance{ - background-image: linear-gradient(60deg, #29323c 0%, #485563 100%); -} - -/*101 Palo Alto*/ -.palo_alto{ - background-image: linear-gradient(-60deg, #16a085 0%, #f4d03f 100%); -} - -/*102 Happy Memories*/ -.happy_memories{ - background-image: linear-gradient(-60deg, #ff5858 0%, #f09819 100%); -} - -/*103 Midnight Bloom*/ -.midnight_bloom{ - background-image: linear-gradient(-20deg, #2b5876 0%, #4e4376 100%); -} - -/*104 Crystalline*/ -.crystalline{ - background-image: linear-gradient(-20deg, #00cdac 0%, #8ddad5 100%); -} - -/*105 Raccoon Back*/ -.raccoon_back{ - background: linear-gradient(-180deg, #BCC5CE 0%, #929EAD 98%), radial-gradient(at top left, rgba(255,255,255,0.30) 0%, rgba(0,0,0,0.30) 100%); - background-blend-mode: screen; -} - -/*106 Party Bliss*/ -.party_bliss{ - background-image: linear-gradient(to top, #4481eb 0%, #04befe 100%); -} - -/*107 Confident Cloud*/ -.confident_cloud{ - background-image: linear-gradient(to top, #dad4ec 0%, #dad4ec 1%, #f3e7e9 100%); -} - -/*108 Le Cocktail*/ -.le_cocktail{ - background-image: linear-gradient(45deg, #874da2 0%, #c43a30 100%); -} - -/*109 River City*/ -.river_city{ - background-image: linear-gradient(to top, #4481eb 0%, #04befe 100%); -} - -/*110 Frozen Berry*/ -.frozen_berry{ - background-image: linear-gradient(to top, #e8198b 0%, #c7eafd 100%); -} - -/*111 Elegance*/ -.elegance{ - background-image: radial-gradient(73% 147%, #EADFDF 59%, #ECE2DF 100%), radial-gradient(91% 146%, rgba(255,255,255,0.50) 47%, rgba(0,0,0,0.50) 100%); - background-blend-mode: screen; -} - -/*112 Child Care*/ -.child_care{ - background-image: linear-gradient(-20deg, #f794a4 0%, #fdd6bd 100%); -} - -/*113 Flying Lemon*/ -.flying_lemon{ - background-image: linear-gradient(60deg, #64b3f4 0%, #c2e59c 100%); -} - -/*114 New Retrowave*/ -.new_retrowave{ - background-image: linear-gradient(to top, #3b41c5 0%, #a981bb 49%, #ffc8a9 100%); -} - -/*115 Hidden Jaguar*/ -.hidden_jaguar{ - background-image: linear-gradient(to top, #0fd850 0%, #f9f047 100%); -} - -/*116 Above The Sky*/ -.above_the_sky{ - background-image: linear-gradient(to top, lightgrey 0%, lightgrey 1%, #e0e0e0 26%, #efefef 48%, #d9d9d9 75%, #bcbcbc 100%); -} - -/*117 Nega*/ -.nega{ - background-image: linear-gradient(45deg, #ee9ca7 0%, #ffdde1 100%); -} - -/*118 Dense Water*/ -.dense_water{ - background-image: linear-gradient(to right, #3ab5b0 0%, #3d99be 31%, #56317a 100%); -} - -/*119 Chemic Aqua*/ -.chemic_aqua{ - background: #CDDCDC radial-gradient(at 50% 100%, rgba(255, 255, 255, 0.50) 0%, rgba(0, 0, 0, 0.50) 100%), linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 0%, rgba(0, 0, 0, 0.25) 100%); - background-blend-mode: screen, overlay; -} - -/*120 Seashore*/ -.seashore{ - background-image: linear-gradient(to top, #209cff 0%, #68e0cf 100%); -} - -/*121 Marble Wall*/ -.marble_wall{ - background-image: linear-gradient(to top, #bdc2e8 0%, #bdc2e8 1%, #e6dee9 100%); -} - -/*122 Cheerful Caramel*/ -.cheerful_caramel{ - background-image: linear-gradient(to top, #e6b980 0%, #eacda3 100%); -} - -/*123 Night Sky*/ -.night_sky{ - background-image: linear-gradient(to top, #1e3c72 0%, #1e3c72 1%, #2a5298 100%); -} - -/*124 Magic Lake*/ -.magic_lake{ - background-image: linear-gradient(to top, #d5dee7 0%, #ffafbd 0%, #c9ffbf 100%); -} - -/*125 Young Grass*/ -.young_grass{ - background-image: linear-gradient(to top, #9be15d 0%, #00e3ae 100%); -} - -/*126 Colorful Peach*/ -.colorful_peach{ - background-image: linear-gradient(to right, #ed6ea0 0%, #ec8c69 100%); -} - -/*127 Gentle Care*/ -.gentle_care{ - background-image: linear-gradient(to right, #ffc3a0 0%, #ffafbd 100%); -} - -/*128 Plum Bath*/ -.plum_bath{ - background-image: linear-gradient(to top, #cc208e 0%, #6713d2 100%); -} - -/*129 Happy Unicorn*/ -.happy_unicorn{ - background-image: linear-gradient(to top, #b3ffab 0%, #12fff7 100%); -} - -/*130 Full Metal*/ -.full_metal{ - background: linear-gradient(to bottom, #D5DEE7 0%, #E8EBF2 50%, #E2E7ED 100%), linear-gradient(to bottom, rgba(0,0,0,0.02) 50%, rgba(255,255,255,0.02) 61%, rgba(0,0,0,0.02) 73%), linear-gradient(33deg, rgba(255,255,255,0.20) 0%, rgba(0,0,0,0.20) 100%); - background-blend-mode: normal,color-burn; -} - -/*131 African Field*/ -.african_field{ - background-image: linear-gradient(to top, #65bd60 0%, #5ac1a8 25%, #3ec6ed 50%, #b7ddb7 75%, #fef381 100%); -} - -/*132 Solid Stone*/ -.solid_stone{ - background-image: linear-gradient(to right, #243949 0%, #517fa4 100%); -} - -/*133 Orange Juice*/ -.orange_juice{ - background-image: linear-gradient(-20deg, #fc6076 0%, #ff9a44 100%); -} - -/*134 Glass Water*/ -.glass_water{ - background-image: linear-gradient(to top, #dfe9f3 0%, white 100%); -} - -/*135 Slick Carbon*/ -.slick_carbon{ - background: linear-gradient(to bottom, #323232 0%, #3F3F3F 40%, #1C1C1C 150%), linear-gradient(to top, rgba(255,255,255,0.40) 0%, rgba(0,0,0,0.25) 200%); - background-blend-mode: multiply; -} - -/*136 North Miracle*/ -.north_miracle{ - background-image: linear-gradient(to right, #00dbde 0%, #fc00ff 100%); -} - -/*137 Fruit Blend*/ -.fruit_blend{ - background-image: linear-gradient(to right, #f9d423 0%, #ff4e50 100%); -} - -/*138 Millennium Pine*/ -.millennium_pine{ - background-image: linear-gradient(to top, #50cc7f 0%, #f5d100 100%); -} - -/*139 High Flight*/ -.high_flight{ - background-image: linear-gradient(to right, #0acffe 0%, #495aff 100%); -} - -/*140 Mole Hall*/ -.mole_hall{ - background-image: linear-gradient(-20deg, #616161 0%, #9bc5c3 100%); -} - -/*141 Earl Gray*/ -.earl_gray{ - background: #E4E4E1 radial-gradient(at top center, rgba(255, 255, 255, 0.03) 0%, rgba(0, 0, 0, 0.03) 100%), linear-gradient(to top, rgba(255, 255, 255, 0.1) 0%, rgba(143, 152, 157, 0.60) 100%); - background-blend-mode: normal, multiply; -} - -/*142 Space Shift*/ -.space_shift{ - background-image: linear-gradient(60deg, #3d3393 0%, #2b76b9 37%, #2cacd1 65%, #35eb93 100%); -} - -/*143 Forest Inei*/ -.forest_inei{ - background-image: linear-gradient(to top, #df89b5 0%, #bfd9fe 100%); -} - -/*144 Royal Garden*/ -.royal_garden{ - background-image: linear-gradient(to right, #ed6ea0 0%, #ec8c69 100%); -} - -/*145 Rich Metal*/ -.rich_metal{ - background-image: linear-gradient(to right, #d7d2cc 0%, #304352 100%); -} - -/*146 Juicy Cake*/ -.juicy_cake{ - background-image: linear-gradient(to top, #e14fad 0%, #f9d423 100%); -} - -/*147 Smart Indigo*/ -.smart_indigo{ - background-image: linear-gradient(to top, #b224ef 0%, #7579ff 100%); -} - -/*148 Sand Strike*/ -.sand_strike{ - background-image: linear-gradient(to right, #c1c161 0%, #c1c161 0%, #d4d4b1 100%); -} - -/*149 Norse Beauty*/ -.norse_beauty{ - background-image: linear-gradient(to right, #ec77ab 0%, #7873f5 100%); -} - -/*150 Aqua Guidance*/ -.aqua_guidance{ - background-image: linear-gradient(to top, #007adf 0%, #00ecbc 100%); -} - -/*151 Sun Veggie*/ -.sun_veggie{ - background-image: linear-gradient(-225deg, #20E2D7 0%, #F9FEA5 100%); -} - -/*152 Sea Lord*/ -.sea_lord{ - background-image: linear-gradient(-225deg, #2CD8D5 0%, #C5C1FF 56%, #FFBAC3 100%); -} - -/*153 Black Sea*/ -.black_sea{ - background-image: linear-gradient(-225deg, #2CD8D5 0%, #6B8DD6 48%, #8E37D7 100%); -} - -/*154 Grass Shampoo*/ -.grass_shampoo{ - background-image: linear-gradient(-225deg, #DFFFCD 0%, #90F9C4 48%, #39F3BB 100%); -} - -/*155 Landing Aircraft*/ -.landing_aircraft{ - background-image: linear-gradient(-225deg, #5D9FFF 0%, #B8DCFF 48%, #6BBBFF 100%); -} - -/*156 Witch Dance*/ -.witch_dance{ - background-image: linear-gradient(-225deg, #A8BFFF 0%, #884D80 100%); -} - -/*157 Sleepless Night*/ -.sleepless_night{ - background-image: linear-gradient(-225deg, #5271C4 0%, #B19FFF 48%, #ECA1FE 100%); -} - -/*158 Angel Care*/ -.angel_care{ - background-image: linear-gradient(-225deg, #FFE29F 0%, #FFA99F 48%, #FF719A 100%); -} - -/*159 Crystal River*/ -.crystal_river{ - background-image: linear-gradient(-225deg, #22E1FF 0%, #1D8FE1 48%, #625EB1 100%); -} - -/*160 Soft Lipstick*/ -.soft_lipstick{ - background-image: linear-gradient(-225deg, #B6CEE8 0%, #F578DC 100%); -} - -/*161 Salt Mountain*/ -.salt_mountain{ - background-image: linear-gradient(-225deg, #FFFEFF 0%, #D7FFFE 100%); -} - -/*162 Perfect White*/ -.perfect_white{ - background-image: linear-gradient(-225deg, #E3FDF5 0%, #FFE6FA 100%); -} - -/*163 Fresh Oasis*/ -.fresh_oasis{ - background-image: linear-gradient(-225deg, #7DE2FC 0%, #B9B6E5 100%); -} - -/*164 Strict November*/ -.strict_november{ - background-image: linear-gradient(-225deg, #CBBACC 0%, #2580B3 100%); -} - -/*165 Morning Salad*/ -.morning_salad{ - background-image: linear-gradient(-225deg, #B7F8DB 0%, #50A7C2 100%); -} - -/*166 Deep Relief*/ -.deep_relief{ - background-image: linear-gradient(-225deg, #7085B6 0%, #87A7D9 50%, #DEF3F8 100%); -} - -/*167 Sea Strike*/ -.sea_strike{ - background-image: linear-gradient(-225deg, #77FFD2 0%, #6297DB 48%, #1EECFF 100%); -} - -/*168 Night Call*/ -.night_call{ - background-image: linear-gradient(-225deg, #AC32E4 0%, #7918F2 48%, #4801FF 100%); -} - -/*169 Supreme Sky*/ -.supreme_sky{ - background-image: linear-gradient(-225deg, #D4FFEC 0%, #57F2CC 48%, #4596FB 100%); -} - -/*170 Light Blue*/ -.light_blue{ - background-image: linear-gradient(-225deg, #9EFBD3 0%, #57E9F2 48%, #45D4FB 100%); -} - -/*171 Mind Crawl*/ -.mind_crawl{ - background-image: linear-gradient(-225deg, #473B7B 0%, #3584A7 51%, #30D2BE 100%); -} - -/*172 Lily Meadow*/ -.lily_meadow{ - background-image: linear-gradient(-225deg, #65379B 0%, #886AEA 53%, #6457C6 100%); -} - -/*173 Sugar Lollipop*/ -.sugar_lollipop{ - background-image: linear-gradient(-225deg, #A445B2 0%, #D41872 52%, #FF0066 100%); -} - -/*174 Sweet Dessert*/ -.sweet_dessert{ - background-image: linear-gradient(-225deg, #7742B2 0%, #F180FF 52%, #FD8BD9 100%); -} - -/*175 Magic Ray*/ -.magic_ray{ - background-image: linear-gradient(-225deg, #FF3CAC 0%, #562B7C 52%, #2B86C5 100%); -} - -/*176 Teen Party*/ -.teen_party{ - background-image: linear-gradient(-225deg, #FF057C 0%, #8D0B93 50%, #321575 100%); -} - -/*177 Frozen Heat*/ -.frozen_heat{ - background-image: linear-gradient(-225deg, #FF057C 0%, #7C64D5 48%, #4CC3FF 100%); -} - -/*178 Gagarin View*/ -.gagarin_view{ - background-image: linear-gradient(-225deg, #69EACB 0%, #EACCF8 48%, #6654F1 100%); -} - -/*179 Fabled Sunset*/ -.fabled_sunset{ - background-image: linear-gradient(-225deg, #231557 0%, #44107A 29%, #FF1361 67%, #FFF800 100%); -} - -/*180 Perfect Blue*/ -.perfect_blue{ - background-image: linear-gradient(-225deg, #3D4E81 0%, #5753C9 48%, #6E7FF3 100%); -} -- cgit v1.2.3 From d6266c757d2f2ea4ff1e71dc8545f9bf97aa3bb1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Dec 2019 13:19:37 +0100 Subject: Replace usages of QVariant::value by qvariant_cast This is done automatically with a clazy check Change-Id: I3b59511d3d36d416c8eda74858ead611d327b116 Reviewed-by: Lars Knoll --- src/gui/image/qimagereader.cpp | 2 +- src/gui/image/qimagewriter.cpp | 2 +- src/gui/text/qfontengine_qpf2.cpp | 16 ++++++++-------- src/gui/text/qsyntaxhighlighter.cpp | 2 +- src/gui/util/qshadergenerator.cpp | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 5e3b608d20..6139cf99c9 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1089,7 +1089,7 @@ QList QImageReader::supportedSubTypes() const return QList(); if (d->handler->supportsOption(QImageIOHandler::SupportedSubTypes)) - return d->handler->option(QImageIOHandler::SupportedSubTypes).value< QList >(); + return qvariant_cast >(d->handler->option(QImageIOHandler::SupportedSubTypes)); return QList(); } diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index 9dcc955fe2..512da5c432 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -561,7 +561,7 @@ QList QImageWriter::supportedSubTypes() const { if (!supportsOption(QImageIOHandler::SupportedSubTypes)) return QList(); - return d->handler->option(QImageIOHandler::SupportedSubTypes).value< QList >(); + return qvariant_cast >(d->handler->option(QImageIOHandler::SupportedSubTypes)); } /*! diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp index d22239c040..e00f9d058c 100644 --- a/src/gui/text/qfontengine_qpf2.cpp +++ b/src/gui/text/qfontengine_qpf2.cpp @@ -456,7 +456,7 @@ glyph_metrics_t QFontEngineQPF2::boundingBox(glyph_t glyph) QFixed QFontEngineQPF2::ascent() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value()); + return QFixed::fromReal(qvariant_cast(extractHeaderField(fontData, Tag_Ascent))); } QFixed QFontEngineQPF2::capHeight() const @@ -466,37 +466,37 @@ QFixed QFontEngineQPF2::capHeight() const QFixed QFontEngineQPF2::descent() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value()); + return QFixed::fromReal(qvariant_cast(extractHeaderField(fontData, Tag_Descent))); } QFixed QFontEngineQPF2::leading() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_Leading).value()); + return QFixed::fromReal(qvariant_cast(extractHeaderField(fontData, Tag_Leading))); } qreal QFontEngineQPF2::maxCharWidth() const { - return extractHeaderField(fontData, Tag_MaxCharWidth).value(); + return qvariant_cast(extractHeaderField(fontData, Tag_MaxCharWidth)); } qreal QFontEngineQPF2::minLeftBearing() const { - return extractHeaderField(fontData, Tag_MinLeftBearing).value(); + return qvariant_cast(extractHeaderField(fontData, Tag_MinLeftBearing)); } qreal QFontEngineQPF2::minRightBearing() const { - return extractHeaderField(fontData, Tag_MinRightBearing).value(); + return qvariant_cast(extractHeaderField(fontData, Tag_MinRightBearing)); } QFixed QFontEngineQPF2::underlinePosition() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_UnderlinePosition).value()); + return QFixed::fromReal(qvariant_cast(extractHeaderField(fontData, Tag_UnderlinePosition))); } QFixed QFontEngineQPF2::lineThickness() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_LineThickness).value()); + return QFixed::fromReal(qvariant_cast(extractHeaderField(fontData, Tag_LineThickness))); } bool QFontEngineQPF2::isValid() const diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index c345e89a21..b50957d63d 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -299,7 +299,7 @@ QSyntaxHighlighter::QSyntaxHighlighter(QObject *parent) : QObject(*new QSyntaxHighlighterPrivate, parent) { if (parent && parent->inherits("QTextEdit")) { - QTextDocument *doc = parent->property("document").value(); + QTextDocument *doc = qvariant_cast(parent->property("document")); if (doc) setDocument(doc); } diff --git a/src/gui/util/qshadergenerator.cpp b/src/gui/util/qshadergenerator.cpp index bcb985de54..4beed8ed25 100644 --- a/src/gui/util/qshadergenerator.cpp +++ b/src/gui/util/qshadergenerator.cpp @@ -273,11 +273,11 @@ namespace const QByteArray placeholder = QByteArray(QByteArrayLiteral("$") + parameterName.toUtf8()); const QVariant parameter = node.parameter(parameterName); if (parameter.userType() == qMetaTypeId()) { - const QShaderLanguage::StorageQualifier qualifier = parameter.value(); + const QShaderLanguage::StorageQualifier qualifier = qvariant_cast(parameter); const QByteArray value = toGlsl(qualifier, format); result.replace(placeholder, value); } else if (parameter.userType() == qMetaTypeId()) { - const QShaderLanguage::VariableType type = parameter.value(); + const QShaderLanguage::VariableType type = qvariant_cast(parameter); const QByteArray value = toGlsl(type); result.replace(placeholder, value); } else { -- cgit v1.2.3 From 98f19f00361bf25097281cae5dfa833ba7db8a2f Mon Sep 17 00:00:00 2001 From: Marius Kittler Date: Sat, 7 Sep 2019 20:05:42 +0200 Subject: Use pkg-config to find libjpeg Change-Id: I42d877fbca5d746114cc28f8ee4db3e54754cd24 Reviewed-by: Thiago Macieira --- src/gui/configure.json | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/configure.json b/src/gui/configure.json index 19312d245d..0202f17b21 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -374,6 +374,7 @@ }, "headers": "jpeglib.h", "sources": [ + { "type": "pkgConfig", "args": "libjpeg" }, { "libs": "-llibjpeg", "condition": "config.msvc" }, "-ljpeg" ] -- cgit v1.2.3 From a1a3a7cd8abbfcc778c3b57953fd931c87a49278 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 12 Dec 2019 11:36:47 +0100 Subject: Avoid crashing when constructing color-space from invalid enum This is not to be taken as supported and is still undefined behavior, but I prefer we do not crash. Change-Id: Icf4f3398bfd57fcbdc611a5a821a1f2de0838330 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qcolorspace.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gui') diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp index 9631fdb416..0fb0e9ee33 100644 --- a/src/gui/painting/qcolorspace.cpp +++ b/src/gui/painting/qcolorspace.cpp @@ -422,6 +422,10 @@ QColorSpace::QColorSpace() */ QColorSpace::QColorSpace(NamedColorSpace namedColorSpace) { + if (namedColorSpace < QColorSpace::SRgb || namedColorSpace > QColorSpace::ProPhotoRgb) { + qWarning() << "QColorSpace attempted constructed from invalid QColorSpace::NamedColorSpace: " << int(namedColorSpace); + return; + } static QColorSpacePrivate *predefinedColorspacePrivates[QColorSpace::ProPhotoRgb + 1]; if (!predefinedColorspacePrivates[namedColorSpace]) { predefinedColorspacePrivates[namedColorSpace] = new QColorSpacePrivate(namedColorSpace); -- cgit v1.2.3 From 8d2a6b422f9180ba053f22d7f8583ad559b3e9ca Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 18 Feb 2019 21:46:33 +0100 Subject: QTextDocument: compile with QT_NO_PRINTER The implementation of QTextDocument::print() is not available when QT_NO_PRINTER is defined but the declaration was so when someone is using this function (and QT_NO_PRINTER) a linker error will occur. Fixes: QTBUG-56916 Change-Id: I49aaaa643c4d8587a66fc95733060cea11994872 Reviewed-by: Volker Hilsheimer --- src/gui/text/qtextdocument.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui') diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index 7d46238257..2459c78768 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -221,7 +221,9 @@ public: bool isModified() const; +#ifndef QT_NO_PRINTER void print(QPagedPaintDevice *printer) const; +#endif enum ResourceType { UnknownResource = 0, -- cgit v1.2.3 From 05d52685028a46e340d610093c7e7c98479ac18b Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 17 Dec 2019 13:13:16 +0100 Subject: Fix QPainter::drawLines() with cosmetic pen Even though each line in the array passed to drawLines() should be rendered as an independent line, some state was kept in the cosmetic stroker from one line to the next. This could result in visible rendering errors. Fixes: QTBUG-80834 Change-Id: Ief7bf78eab83ae34459802bff5a57d6beec4a5e5 Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qcosmeticstroker.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 0fb89a75b5..fa34c5598e 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -375,6 +375,7 @@ void QCosmeticStroker::drawLine(const QPointF &p1, const QPointF &p2) patternOffset = state->lastPen.dashOffset()*64; lastPixel.x = INT_MIN; + lastPixel.y = INT_MIN; stroke(this, start.x(), start.y(), end.x(), end.y(), drawCaps ? CapBegin|CapEnd : 0); -- cgit v1.2.3 From 87cedab94e4ca17e8c77602c0d1d285e3c68cb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 13 Dec 2019 11:47:42 +0100 Subject: Remove ApplicationResourceFlags::ApplicationPaletteExplicitlySet After 8fb881900c7b it's tracked by AA_SetPalette. Since the latter is publicly observable we remove the internal flag instead. Change-Id: Ie69799f1b45d68017cb9eaab2a9986cc9ac9ca38 Reviewed-by: Timur Pocheptsov Reviewed-by: Friedemann Kleint --- src/gui/kernel/qguiapplication.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 54f3996b6e..e534ba377f 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -166,7 +166,6 @@ bool QGuiApplicationPrivate::is_fallback_session_management_enabled = true; enum ApplicationResourceFlags { - ApplicationPaletteExplicitlySet = 0x1, ApplicationFontExplicitlySet = 0x2 }; @@ -3297,7 +3296,6 @@ void QGuiApplication::setPalette(const QPalette &pal) else *QGuiApplicationPrivate::app_pal = pal; - applicationResourceFlags |= ApplicationPaletteExplicitlySet; QCoreApplication::setAttribute(Qt::AA_SetPalette); if (qGuiApp) @@ -4100,8 +4098,7 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) void QGuiApplicationPrivate::notifyThemeChanged() { - if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet) && - !QCoreApplication::testAttribute(Qt::AA_SetPalette)) { + if (!testAttribute(Qt::AA_SetPalette)) { clearPalette(); initPalette(); emit qGuiApp->paletteChanged(*app_pal); -- cgit v1.2.3 From 04f5008f51dee9feec68afcee8cd8314b8e5ac62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 25 Jun 2019 18:42:59 +0200 Subject: Let sendApplicationPaletteChange() decide when it needs to exit early Change-Id: I7a8e6c0b54d2a16a17b292a4102e05f743bcbe29 Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qguiapplication.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index e534ba377f..bab525f809 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -4102,8 +4102,7 @@ void QGuiApplicationPrivate::notifyThemeChanged() clearPalette(); initPalette(); emit qGuiApp->paletteChanged(*app_pal); - if (is_app_running && !is_app_closing) - sendApplicationPaletteChange(); + sendApplicationPaletteChange(); } if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { const auto locker = qt_scoped_lock(applicationFontMutex); @@ -4118,6 +4117,9 @@ void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, con Q_UNUSED(toAllWidgets) Q_UNUSED(className) + if (!is_app_running || is_app_closing) + return; + QEvent event(QEvent::ApplicationPaletteChange); QGuiApplication::sendEvent(QGuiApplication::instance(), &event); } -- cgit v1.2.3 From 0a09a6341ddff4397461deb98b8d7a28ca3c9dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 25 Jun 2019 18:36:04 +0200 Subject: Sync implementation of QGuiApplication and QApplication setPalette The two static setPalette methods in QApplication and QGuiApplication should have the same behavior in terms of what signals and events they emit. Change-Id: I54579d490e31f3783e2d4fea689ca799a070ff1d Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qguiapplication.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bab525f809..7adba40fbd 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3299,7 +3299,7 @@ void QGuiApplication::setPalette(const QPalette &pal) QCoreApplication::setAttribute(Qt::AA_SetPalette); if (qGuiApp) - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + qGuiApp->d_func()->sendApplicationPaletteChange(); } void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) @@ -4101,7 +4101,6 @@ void QGuiApplicationPrivate::notifyThemeChanged() if (!testAttribute(Qt::AA_SetPalette)) { clearPalette(); initPalette(); - emit qGuiApp->paletteChanged(*app_pal); sendApplicationPaletteChange(); } if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { @@ -4115,7 +4114,9 @@ void QGuiApplicationPrivate::notifyThemeChanged() void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) { Q_UNUSED(toAllWidgets) - Q_UNUSED(className) + + if (!className) + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); if (!is_app_running || is_app_closing) return; -- cgit v1.2.3 From 52876e0a821126ea07cb1c5db8f064c3585b6d96 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 17 Dec 2019 17:20:44 +0100 Subject: Basic QImage cleanup Remove deprecated methods and do marked TODOs for Qt6. Change-Id: I905743cf909776c6433616b3a7c3b544d75f2afe Reviewed-by: Eirik Aavitsland --- src/gui/doc/src/dontdocument.qdoc | 2 +- src/gui/image/qimage.cpp | 155 -------------------------------------- src/gui/image/qimage.h | 146 ----------------------------------- 3 files changed, 1 insertion(+), 302 deletions(-) (limited to 'src/gui') diff --git a/src/gui/doc/src/dontdocument.qdoc b/src/gui/doc/src/dontdocument.qdoc index b360acefc1..6b50daba88 100644 --- a/src/gui/doc/src/dontdocument.qdoc +++ b/src/gui/doc/src/dontdocument.qdoc @@ -27,7 +27,7 @@ /*! \dontdocument (QTypeInfo QScreenOrientationChangeEvent QApplicationStateChangeEvent - QImageTextKeyLang QMetaTypeId QAbstractUndoItem + QMetaTypeId QAbstractUndoItem QOpenGLVersionStatus QOpenGLVersionFunctionsBackend QOpenGLVersionFunctionsStorage diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 99d64737c5..1c8c6262ce 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1381,11 +1381,7 @@ int QImage::colorCount() const \sa colorTable(), setColor(), {QImage#Image Transformations}{Image Transformations} */ -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) void QImage::setColorTable(const QVector &colors) -#else -void QImage::setColorTable(const QVector colors) -#endif { if (!d) return; @@ -1395,11 +1391,7 @@ void QImage::setColorTable(const QVector colors) if (!d) return; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) d->colortable = colors; -#else - d->colortable = std::move(const_cast&>(colors)); -#endif d->has_alpha_clut = false; for (int i = 0; i < d->colortable.size(); ++i) { if (qAlpha(d->colortable.at(i)) != 255) { @@ -1472,25 +1464,6 @@ void QImage::setDevicePixelRatio(qreal scaleFactor) d->devicePixelRatio = scaleFactor; } -#if QT_DEPRECATED_SINCE(5, 10) -/*! - \since 4.6 - \obsolete - Returns the number of bytes occupied by the image data. - - Note this method should never be called on an image larger than 2 gigabytes. - Instead use sizeInBytes(). - - \sa sizeInBytes(), bytesPerLine(), bits(), {QImage#Image Information}{Image - Information} -*/ -int QImage::byteCount() const -{ - Q_ASSERT(!d || d->nbytes < std::numeric_limits::max()); - return d ? int(d->nbytes) : 0; -} -#endif - /*! \since 5.10 Returns the image data size in bytes. @@ -1510,17 +1483,10 @@ qsizetype QImage::sizeInBytes() const \sa scanLine() */ -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) qsizetype QImage::bytesPerLine() const { return d ? d->bytes_per_line : 0; } -#else -int QImage::bytesPerLine() const -{ - return d ? d->bytes_per_line : 0; -} -#endif /*! @@ -4053,72 +4019,11 @@ void QImage::setText(const QString &key, const QString &value) d->text.insert(key, value); } -/*! - \fn QString QImage::text(const char* key, const char* language) const - \obsolete - - Returns the text recorded for the given \a key in the given \a - language, or in a default language if \a language is 0. - - Use text() instead. - - The language the text is recorded in is no longer relevant since - the text is always set using QString and UTF-8 representation. -*/ - -/*! - \fn QString QImage::text(const QImageTextKeyLang& keywordAndLanguage) const - \overload - \obsolete - - Returns the text recorded for the given \a keywordAndLanguage. - - Use text() instead. - - The language the text is recorded in is no longer relevant since - the text is always set using QString and UTF-8 representation. -*/ - -/*! - \fn void QImage::setText(const char* key, const char* language, const QString& text) - \obsolete - - Sets the image text to the given \a text and associate it with the - given \a key. The text is recorded in the specified \a language, - or in a default language if \a language is 0. - - Use setText() instead. - - The language the text is recorded in is no longer relevant since - the text is always set using QString and UTF-8 representation. - - \omit - Records string \a for the keyword \a key. The \a key should be - a portable keyword recognizable by other software - some suggested - values can be found in - \l{http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.Anc-text} - {the PNG specification}. \a s can be any text. \a lang should - specify the language code (see - \l{http://www.rfc-editor.org/rfc/rfc1766.txt}{RFC 1766}) or 0. - \endomit -*/ - -/* - Sets the image bits to the \a pixmap contents and returns a - reference to the image. - - If the image shares data with other images, it will first - dereference the shared data. - - Makes a call to QPixmap::convertToImage(). -*/ - /*! \internal Used by QPainter to retrieve a paint engine for the image. */ - QPaintEngine *QImage::paintEngine() const { if (!d) @@ -4364,22 +4269,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth #undef IWX_LSB #undef IWX_PIX -/*! \fn int QImage::serialNumber() const - \obsolete - Returns a number that identifies the contents of this - QImage object. Distinct QImage objects can only have the same - serial number if they refer to the same contents (but they don't - have to). - - Use cacheKey() instead. - - \warning The serial number doesn't necessarily change when the - image is altered. This means that it may be dangerous to use - it as a cache key. - - \sa operator==() -*/ - /*! Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same key if they @@ -5122,50 +5011,6 @@ QDebug operator<<(QDebug dbg, const QImage &i) } #endif -/*! - \fn void QImage::setNumColors(int n) - \obsolete - - Resizes the color table to contain \a n entries. - - \sa setColorCount() - */ - -/*! - \fn int QImage::numBytes() const - \obsolete - - Returns the number of bytes occupied by the image data. - - \sa sizeInBytes() - */ - -/*! - \fn QStringList QImage::textLanguages() const - \obsolete - - Returns the language identifiers for which some texts are recorded. - Note that if you want to iterate over the list, you should iterate over a copy. - - The language the text is recorded in is no longer relevant since the text is - always set using QString and UTF-8 representation. - - \sa textKeys() - */ - -/*! - \fn QList QImage::textList() const - \obsolete - - Returns a list of QImageTextKeyLang objects that enumerate all the texts - key/language pairs set for this image. - - The language the text is recorded in is no longer relevant since the text - is always set using QString and UTF-8 representation. - - \sa textKeys() - */ - static Q_CONSTEXPR QPixelFormat pixelformats[] = { //QImage::Format_Invalid: QPixelFormat(), diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 73c960f13f..1e462fc2e6 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -50,10 +50,6 @@ #include #include -#if QT_DEPRECATED_SINCE(5, 0) -#include -#endif - #if defined(Q_OS_DARWIN) || defined(Q_QDOC) Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGImage); #endif @@ -71,27 +67,6 @@ class QVariant; template class QVector; struct QImageData; -class QImageDataMisc; // internal -#if QT_DEPRECATED_SINCE(5, 0) -class QImageTextKeyLang { -public: - QT_DEPRECATED QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { } - QT_DEPRECATED QImageTextKeyLang() { } - - QByteArray key; - QByteArray lang; - - bool operator< (const QImageTextKeyLang& other) const - { return key < other.key || (key==other.key && lang < other.lang); } - bool operator== (const QImageTextKeyLang& other) const - { return key==other.key && lang==other.lang; } - inline bool operator!= (const QImageTextKeyLang &other) const - { return !operator==(other); } -private: - friend class QImage; - QImageTextKeyLang(bool /*dummy*/) {} -}; -#endif typedef void (*QImageCleanupFunction)(void*); @@ -212,19 +187,12 @@ public: const uchar *bits() const; const uchar *constBits() const; -#if QT_DEPRECATED_SINCE(5, 10) - QT_DEPRECATED_X("Use sizeInBytes") int byteCount() const; -#endif qsizetype sizeInBytes() const; uchar *scanLine(int); const uchar *scanLine(int) const; const uchar *constScanLine(int) const; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) qsizetype bytesPerLine() const; -#else - int bytesPerLine() const; -#endif bool valid(int x, int y) const; bool valid(const QPoint &pt) const; @@ -245,11 +213,7 @@ public: void setPixelColor(const QPoint &pt, const QColor &c); QVector colorTable() const; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) void setColorTable(const QVector &colors); -#else - void setColorTable(const QVector colors); -#endif qreal devicePixelRatio() const; void setDevicePixelRatio(qreal scaleFactor); @@ -309,9 +273,6 @@ public: inline static QImage fromData(const QByteArray &data, const char *format = nullptr) { return fromData(reinterpret_cast(data.constData()), data.size(), format); } -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } -#endif qint64 cacheKey() const; QPaintEngine *paintEngine() const override; @@ -337,20 +298,6 @@ public: CGImageRef toCGImage() const Q_DECL_CF_RETURNS_RETAINED; #endif -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED inline QString text(const char *key, const char *lang = nullptr) const; - QT_DEPRECATED inline QList textList() const; - QT_DEPRECATED inline QStringList textLanguages() const; - QT_DEPRECATED inline QString text(const QImageTextKeyLang&) const; - QT_DEPRECATED inline void setText(const char* key, const char* lang, const QString&); -#endif - -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED inline int numColors() const; - QT_DEPRECATED inline void setNumColors(int); - QT_DEPRECATED inline int numBytes() const; -#endif - protected: virtual int metric(PaintDeviceMetric metric) const override; QImage mirrored_helper(bool horizontal, bool vertical) const; @@ -385,99 +332,6 @@ inline void QImage::setPixel(const QPoint &pt, uint index_or_rgb) { setPixel(pt. inline QColor QImage::pixelColor(const QPoint &pt) const { return pixelColor(pt.x(), pt.y()); } inline void QImage::setPixelColor(const QPoint &pt, const QColor &c) { setPixelColor(pt.x(), pt.y(), c); } -#if QT_DEPRECATED_SINCE(5, 0) - -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - -inline QString QImage::text(const char* key, const char* lang) const -{ - if (!d) - return QString(); - QString k = QString::fromLatin1(key); - if (lang && *lang) - k += QLatin1Char('/') + QString::fromLatin1(lang); - return text(k); -} - -inline QList QImage::textList() const -{ - QList imageTextKeys; - if (!d) - return imageTextKeys; - QStringList keys = textKeys(); - for (int i = 0; i < keys.size(); ++i) { - int index = keys.at(i).indexOf(QLatin1Char('/')); - if (index > 0) { - QImageTextKeyLang tkl(true); - tkl.key = keys.at(i).left(index).toLatin1(); - tkl.lang = keys.at(i).mid(index+1).toLatin1(); - imageTextKeys += tkl; - } - } - - return imageTextKeys; -} - -inline QStringList QImage::textLanguages() const -{ - if (!d) - return QStringList(); - QStringList keys = textKeys(); - QStringList languages; - for (int i = 0; i < keys.size(); ++i) { - int index = keys.at(i).indexOf(QLatin1Char('/')); - if (index > 0) - languages += keys.at(i).mid(index+1); - } - - return languages; -} - -inline QString QImage::text(const QImageTextKeyLang&kl) const -{ - if (!d) - return QString(); - QString k = QString::fromLatin1(kl.key.constData()); - if (!kl.lang.isEmpty()) - k += QLatin1Char('/') + QString::fromLatin1(kl.lang.constData()); - return text(k); -} - -inline void QImage::setText(const char* key, const char* lang, const QString &s) -{ - if (!d) - return; - detach(); - - // In case detach() ran out of memory - if (!d) - return; - - QString k = QString::fromLatin1(key); - if (lang && *lang) - k += QLatin1Char('/') + QString::fromLatin1(lang); - setText(k, s); -} - -QT_WARNING_POP - -inline int QImage::numColors() const -{ - return colorCount(); -} - -inline void QImage::setNumColors(int n) -{ - setColorCount(n); -} - -inline int QImage::numBytes() const -{ - return int(sizeInBytes()); -} -#endif - // QImage stream functions #if !defined(QT_NO_DATASTREAM) -- cgit v1.2.3 From f2d752c59f5a1d2e815394d718350d0fcaf43ef6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 6 Dec 2019 14:16:31 +0100 Subject: QWindowSystemInterface: use QBasicMutex and qt_scoped_lock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no reason to use a class-static mutex object here. Use a namespace-static QBasicMutex, port to qt_scoped_lock. Change-Id: Ia9bd3c2fadbf1da25ef79bb393c899b678cbc182 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qwindowsysteminterface.cpp | 10 ++++++---- src/gui/kernel/qwindowsysteminterface_p.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index c9a70897d6..31765cf54c 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -46,7 +46,9 @@ #include #include #include "qhighdpiscaling_p.h" + #include +#include #if QT_CONFIG(draganddrop) #include @@ -623,7 +625,7 @@ bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device) static int g_nextPointId = 1; // map from device-independent point id (arbitrary) to "Qt point" ids -QMutex QWindowSystemInterfacePrivate::pointIdMapMutex; +static QBasicMutex pointIdMapMutex; typedef QMap PointIdMap; Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap) @@ -641,7 +643,7 @@ Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap) */ static int acquireCombinedPointId(quint8 deviceId, int pointId) { - QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); + const auto locker = qt_scoped_lock(pointIdMapMutex); quint64 combinedId64 = (quint64(deviceId) << 32) + pointId; auto it = g_pointIdMap->constFind(combinedId64); @@ -702,7 +704,7 @@ QList } if (states == Qt::TouchPointReleased) { - QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); + const auto locker = qt_scoped_lock(pointIdMapMutex); // All points on deviceId have been released. // Remove all points associated with that device from g_pointIdMap. @@ -723,7 +725,7 @@ QList void QWindowSystemInterfacePrivate::clearPointIdMap() { - QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); + const auto locker = qt_scoped_lock(pointIdMapMutex); g_pointIdMap->clear(); g_nextPointId = 1; } diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 6e4bce607e..dd6f29b41f 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -529,7 +529,6 @@ public: static QWaitCondition eventsFlushed; static QMutex flushEventMutex; - static QMutex pointIdMapMutex; static QAtomicInt eventAccepted; static QList -- cgit v1.2.3 From 62c3dd5632b04a7ee2410cc2233c0d0605ad5bd6 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Fri, 22 Nov 2019 13:04:36 +0100 Subject: QPalette::setBrush: remove a workaround for PlaceholderText This partially reverts ebd3a13b807c6af2684b42d3912549caf7ef82aa removing the part that was intended to be removed in Qt 6. Task-number: QTBUG-78544 Change-Id: I4b7eb922c46e44411717f80234fad8ad7dd09aef Reviewed-by: Shawn Rutledge --- src/gui/kernel/qpalette.cpp | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index fc063bc72c..fdcdef4345 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -321,11 +321,8 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button) Returns the placeholder text brush of the current color group. - \note Before Qt 5.12, the placeholder text color was hard-coded in the code as - QPalette::text().color() where an alpha of 128 was applied. - We continue to support this behavior by default, unless you set your own brush. - One can get back the original placeholder color setting the special QBrush default - constructor as placeholder brush. + \note Before Qt 5.12, the placeholder text color was hard-coded as QPalette::text().color() + with an alpha of 128 applied. In Qt 6, it is an independent color. \sa ColorRole, brush() */ @@ -783,32 +780,11 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) cg = Active; } - // For placeholder we want to continue to respect the original behavior, which is - // derivating the text color, but only if user has not yet set his own brush. - // We then use Qt::NoBrush as an inernal way to know if the brush is customized or not. - - // ### Qt 6 - remove this special case - // Part 1 - Restore initial color to the given color group - if (cr == PlaceholderText && b == QBrush()) { - QColor col = brush(Text).color(); - col.setAlpha(128); - setBrush(cg, PlaceholderText, QBrush(col, Qt::NoBrush)); - return; - } - if (d->br[cg][cr] != b) { detach(); d->br[cg][cr] = b; } data.resolve_mask |= (1<br[cg][PlaceholderText].style() == Qt::NoBrush) { - QColor col = brush(Text).color(); - col.setAlpha(128); - setBrush(cg, PlaceholderText, QBrush(col, Qt::NoBrush)); - } } /*! @@ -1177,6 +1153,8 @@ Q_GUI_EXPORT QPalette qt_fusionPalette() QColor button = backGround; QColor shadow = dark.darker(135); QColor disabledShadow = shadow.lighter(150); + QColor placeholder = text; + placeholder.setAlpha(128); QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base); fusionPalette.setBrush(QPalette::Midlight, midLight); @@ -1194,6 +1172,9 @@ Q_GUI_EXPORT QPalette qt_fusionPalette() fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198)); fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198)); fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145)); + + fusionPalette.setBrush(QPalette::PlaceholderText, placeholder); + return fusionPalette; } -- cgit v1.2.3 From caa82e1fc24907af0a81e31cf9b77ae8e82e44cc Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Wed, 18 Dec 2019 15:27:06 +0100 Subject: Doc: Add since version for QCursor::swap and QOperatingSystemVersion::currentType. Fixes: QTBUG-80854 Fixes: QTBUG-80891 Change-Id: Ia256fa0d3ad4665f44b933f5a4a8d4ee87e9fc13 Reviewed-by: Timur Pocheptsov Reviewed-by: Leena Miettinen --- src/gui/kernel/qcursor.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 1ba8760a9d..fd912362bf 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -175,6 +175,8 @@ QT_BEGIN_NAMESPACE \fn void QCursor::swap(QCursor &other) Swaps this cursor with the \a other cursor. + + \since 5.7 */ /*! -- cgit v1.2.3 From 9a77beaea36bf6c8b44086a15bed0e9903a06944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 18 Dec 2019 18:01:27 +0100 Subject: macOS: Deliver theme changes synchronously Otherwise the expose event that AppKit triggers will be delivered before we've propagated the theme change, and we fail to draw the UI using the new theme. Change-Id: I502122a2bf02a866d136106d831f0c2a0dfe26f2 Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qwindowsysteminterface.cpp | 4 ++-- src/gui/kernel/qwindowsysteminterface.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index ba04f8701d..8457282bed 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -880,10 +880,10 @@ void QWindowSystemInterface::handleScreenRefreshRateChange(QScreen *screen, qrea QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -void QWindowSystemInterface::handleThemeChange(QWindow *window) +QT_DEFINE_QPA_EVENT_HANDLER(void, handleThemeChange, QWindow *window) { QWindowSystemInterfacePrivate::ThemeChangeEvent *e = new QWindowSystemInterfacePrivate::ThemeChangeEvent(window); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } #if QT_CONFIG(draganddrop) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index d5a4ad30d8..95e20f0f8b 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -249,6 +249,7 @@ public: static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY); static void handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate); + template static void handleThemeChange(QWindow *window); static void handleFileOpenEvent(const QString& fileName); -- cgit v1.2.3 From 0f0d26418c185fe9e4c01049d165ac5548305354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 19 Dec 2019 13:51:56 +0100 Subject: High-DPI: restore rounding behavior on Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt 5.14 introduced QApplication::scaleFactorRoundingPolicy, where the default policy rounds the scale factor to an integer, which matches Qt's behavior on Windows and X11. However, Qt has never rounded scale factors on Android. Restore the historical behavior and document the platform difference. Change-Id: I0f8e8fb65e3874338ea290bbb12da350da22f099 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 7adba40fbd..6678b5f0ce 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -148,7 +148,13 @@ QString QGuiApplicationPrivate::styleOverride; Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy = +#ifdef Q_OS_ANDROID + // On Android, Qt has newer rounded the scale factor. Preserve + // that behavior by disabling rounding by default. + Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; +#else Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor; +#endif bool QGuiApplicationPrivate::highDpiScalingUpdated = false; QPointer QGuiApplicationPrivate::currentDragWindow; @@ -3551,6 +3557,8 @@ Qt::ApplicationState QGuiApplication::applicationState() accessor will reflect the environment, if set. The default value is Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor. + On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThough, + which preserves historical behavior from earlier Qt versions. */ void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy) { -- cgit v1.2.3 From 43792c50d4c8de1c30456666cc9ee1c945d67991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 19 Dec 2019 14:05:30 +0100 Subject: =?UTF-8?q?Don=E2=80=99t=20reset=20highDpicaleFactorRoundingPolicy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don’t reset highDpicaleFactorRoundingPolicy in the QGuiApplication destructior. This is a static property, independent of the application object lifetime. Change-Id: Ibf55e2a6ea1ae6429fce3f0e9d58323111aac374 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 6678b5f0ce..d49f349e7a 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -695,8 +695,6 @@ QGuiApplication::~QGuiApplication() QGuiApplicationPrivate::lastCursorPosition = {qInf(), qInf()}; QGuiApplicationPrivate::currentMousePressWindow = QGuiApplicationPrivate::currentMouseWindow = nullptr; QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; - QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy = - Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor; QGuiApplicationPrivate::highDpiScalingUpdated = false; QGuiApplicationPrivate::currentDragWindow = nullptr; QGuiApplicationPrivate::tabletDevicePoints.clear(); -- cgit v1.2.3 From 9d6b4d11424cdcd6c572cdcc50b3b790b6e673c0 Mon Sep 17 00:00:00 2001 From: Jordi Pujol Foyo Date: Fri, 13 Dec 2019 14:27:11 +0100 Subject: New features for QPdfWriter Added new API setDocumentXmpMetadata/documentXmpMetadata and addFileAttachment [ChangeLog][QtGui][QPdfWriter] New API to provide external document XMP metadata and attach files to PDF. Fixes: QTBUG-78651 Fixes: QTBUG-78764 Change-Id: Ic0b37e8d12899f907001db469080594c14c87655 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qpdf.cpp | 159 ++++++++++++++++++++++++++++++++-------- src/gui/painting/qpdf_p.h | 21 +++++- src/gui/painting/qpdfwriter.cpp | 44 +++++++++++ src/gui/painting/qpdfwriter.h | 5 ++ 4 files changed, 196 insertions(+), 33 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 932c3e6f5a..de9fc13331 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1390,6 +1390,18 @@ void QPdfEngine::setPdfVersion(PdfVersion version) d->pdfVersion = version; } +void QPdfEngine::setDocumentXmpMetadata(const QByteArray &xmpMetadata) +{ + Q_D(QPdfEngine); + d->xmpDocumentMetadata = xmpMetadata; +} + +QByteArray QPdfEngine::documentXmpMetadata() const +{ + Q_D(const QPdfEngine); + return d->xmpDocumentMetadata; +} + void QPdfEngine::setPageLayout(const QPageLayout &pageLayout) { Q_D(QPdfEngine); @@ -1520,6 +1532,8 @@ bool QPdfEngine::begin(QPaintDevice *pdev) d->xrefPositions.clear(); d->pageRoot = 0; + d->embeddedfilesRoot = 0; + d->namesRoot = 0; d->catalog = 0; d->info = 0; d->graphicsState = 0; @@ -1555,10 +1569,18 @@ bool QPdfEngine::end() d->outDevice = nullptr; } + d->fileCache.clear(); + setActive(false); return true; } +void QPdfEngine::addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType) +{ + Q_D(QPdfEngine); + d->fileCache.push_back({fileName, data, mimeType}); +} + QPdfEnginePrivate::~QPdfEnginePrivate() { qDeleteAll(fonts); @@ -1586,13 +1608,19 @@ void QPdfEnginePrivate::writeHeader() int metaDataObj = -1; int outputIntentObj = -1; + if (pdfVersion == QPdfEngine::Version_A1b || !xmpDocumentMetadata.isEmpty()) { + metaDataObj = writeXmpDcumentMetaData(); + } if (pdfVersion == QPdfEngine::Version_A1b) { - metaDataObj = writeXmpMetaData(); outputIntentObj = writeOutputIntent(); } catalog = addXrefEntry(-1); pageRoot = requestObject(); + if (!fileCache.isEmpty()) { + namesRoot = requestObject(); + embeddedfilesRoot = requestObject(); + } // catalog { @@ -1602,10 +1630,15 @@ void QPdfEnginePrivate::writeHeader() << "/Type /Catalog\n" << "/Pages " << pageRoot << "0 R\n"; - if (pdfVersion == QPdfEngine::Version_A1b) { - s << "/OutputIntents [" << outputIntentObj << "0 R]\n"; + // Embedded files, if any + if (!fileCache.isEmpty()) + s << "/Names " << embeddedfilesRoot << "0 R\n"; + + if (pdfVersion == QPdfEngine::Version_A1b || !xmpDocumentMetadata.isEmpty()) s << "/Metadata " << metaDataObj << "0 R\n"; - } + + if (pdfVersion == QPdfEngine::Version_A1b) + s << "/OutputIntents [" << outputIntentObj << "0 R]\n"; s << ">>\n" << "endobj\n"; @@ -1613,6 +1646,12 @@ void QPdfEnginePrivate::writeHeader() write(catalog); } + if (!fileCache.isEmpty()) { + addXrefEntry(embeddedfilesRoot); + xprintf("<>\n" + "endobj\n", namesRoot); + } + // graphics state graphicsState = addXrefEntry(-1); xprintf("<<\n" @@ -1664,39 +1703,45 @@ void QPdfEnginePrivate::writeInfo() "endobj\n"); } -int QPdfEnginePrivate::writeXmpMetaData() +int QPdfEnginePrivate::writeXmpDcumentMetaData() { const int metaDataObj = addXrefEntry(-1); + QByteArray metaDataContent; + + if (xmpDocumentMetadata.isEmpty()) { + const QString producer(QString::fromLatin1("Qt " QT_VERSION_STR)); + + const QDateTime now = QDateTime::currentDateTime(); + const QDate date = now.date(); + const QTime time = now.time(); + const QString timeStr = + QString::asprintf("%d-%02d-%02dT%02d:%02d:%02d", + date.year(), date.month(), date.day(), + time.hour(), time.minute(), time.second()); + + const int offset = now.offsetFromUtc(); + const int hours = (offset / 60) / 60; + const int mins = (offset / 60) % 60; + QString tzStr; + if (offset < 0) + tzStr = QString::asprintf("-%02d:%02d", -hours, -mins); + else if (offset > 0) + tzStr = QString::asprintf("+%02d:%02d", hours , mins); + else + tzStr = QLatin1String("Z"); - const QString producer(QString::fromLatin1("Qt " QT_VERSION_STR)); - - const QDateTime now = QDateTime::currentDateTime(); - const QDate date = now.date(); - const QTime time = now.time(); - const QString timeStr = - QString::asprintf("%d-%02d-%02dT%02d:%02d:%02d", - date.year(), date.month(), date.day(), - time.hour(), time.minute(), time.second()); + const QString metaDataDate = timeStr + tzStr; - const int offset = now.offsetFromUtc(); - const int hours = (offset / 60) / 60; - const int mins = (offset / 60) % 60; - QString tzStr; - if (offset < 0) - tzStr = QString::asprintf("-%02d:%02d", -hours, -mins); - else if (offset > 0) - tzStr = QString::asprintf("+%02d:%02d", hours , mins); + QFile metaDataFile(QLatin1String(":/qpdf/qpdfa_metadata.xml")); + metaDataFile.open(QIODevice::ReadOnly); + metaDataContent = QString::fromUtf8(metaDataFile.readAll()).arg(producer.toHtmlEscaped(), + title.toHtmlEscaped(), + creator.toHtmlEscaped(), + metaDataDate).toUtf8(); + } else - tzStr = QLatin1String("Z"); + metaDataContent = xmpDocumentMetadata; - const QString metaDataDate = timeStr + tzStr; - - QFile metaDataFile(QLatin1String(":/qpdf/qpdfa_metadata.xml")); - metaDataFile.open(QIODevice::ReadOnly); - const QByteArray metaDataContent = QString::fromUtf8(metaDataFile.readAll()).arg(producer.toHtmlEscaped(), - title.toHtmlEscaped(), - creator.toHtmlEscaped(), - metaDataDate).toUtf8(); xprintf("<<\n" "/Type /Metadata /Subtype /XML\n" "/Length %d\n" @@ -1774,6 +1819,56 @@ void QPdfEnginePrivate::writePageRoot() "endobj\n"); } +void QPdfEnginePrivate::writeAttachmentRoot() +{ + if (fileCache.isEmpty()) + return; + + QVector attachments; + const int size = fileCache.size(); + for (int i = 0; i < size; ++i) { + auto attachment = fileCache.at(i); + const int attachmentID = addXrefEntry(-1); + xprintf("<<\n"); + if (do_compress) + xprintf("/Filter /FlateDecode\n"); + + const int lenobj = requestObject(); + xprintf("/Length %d 0 R\n", lenobj); + int len = 0; + xprintf(">>\nstream\n"); + len = writeCompressed(attachment.data); + xprintf("\nendstream\n" + "endobj\n"); + addXrefEntry(lenobj); + xprintf("%d\n" + "endobj\n", len); + + attachments.push_back(addXrefEntry(-1)); + xprintf("<<\n" + "/F (%s)", attachment.fileName.toLatin1().constData()); + + xprintf("\n/EF <>\n" + "/Type/Filespec\n" + , attachmentID); + if (!attachment.mimeType.isEmpty()) + xprintf("/Subtype/%s\n", + attachment.mimeType.replace(QLatin1String("/"), + QLatin1String("#2F")).toLatin1().constData()); + xprintf(">>\nendobj\n"); + } + + // names + addXrefEntry(namesRoot); + xprintf("<>\n" + "endobj\n"); +} void QPdfEnginePrivate::embedFont(QFontSubset *font) { @@ -2031,6 +2126,8 @@ void QPdfEnginePrivate::writeTail() writePage(); writeFonts(); writePageRoot(); + writeAttachmentRoot(); + addXrefEntry(xrefPositions.size(),false); xprintf("xref\n" "0 %d\n" diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index 89e549614a..57d70db442 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -187,6 +187,11 @@ public: void setPdfVersion(PdfVersion version); + void setDocumentXmpMetadata(const QByteArray &xmpMetadata); + QByteArray documentXmpMetadata() const; + + void addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType); + // reimplementations QPaintEngine bool begin(QPaintDevice *pdev) override; bool end() override; @@ -297,9 +302,10 @@ private: int createShadingFunction(const QGradient *gradient, int from, int to, bool reflect, bool alpha); void writeInfo(); - int writeXmpMetaData(); + int writeXmpDcumentMetaData(); int writeOutputIntent(); void writePageRoot(); + void writeAttachmentRoot(); void writeFonts(); void embedFont(QFontSubset *font); qreal calcUserUnit() const; @@ -324,11 +330,22 @@ private: inline int writeCompressed(const QByteArray &data) { return writeCompressed(data.constData(), data.length()); } int writeCompressed(QIODevice *dev); + struct AttachmentInfo + { + AttachmentInfo (const QString &fileName, const QByteArray &data, const QString &mimeType) + : fileName(fileName), data(data), mimeType(mimeType) {} + QString fileName; + QByteArray data; + QString mimeType; + }; + // various PDF objects - int pageRoot, catalog, info, graphicsState, patternColorSpace; + int pageRoot, embeddedfilesRoot, namesRoot, catalog, info, graphicsState, patternColorSpace; QVector pages; QHash imageCache; QHash, uint > alphaCache; + QVector fileCache; + QByteArray xmpDocumentMetadata; }; QT_END_NAMESPACE diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 35814d146c..4f70fe6ad2 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -266,6 +266,50 @@ int QPdfWriter::resolution() const return d->engine->resolution(); } +/*! + \since 5.15 + + Sets the document metadata. This metadata is not influenced by the setTitle / setCreator methods, + so is up to the user to keep it consistent. + \a xmpMetadata contains XML formatted metadata to embed into the PDF file. + + \sa documentXmpMetadata() +*/ + +void QPdfWriter::setDocumentXmpMetadata(const QByteArray &xmpMetadata) +{ + Q_D(const QPdfWriter); + d->engine->setDocumentXmpMetadata(xmpMetadata); +} + +/*! + \since 5.15 + + Gets the document metadata, as it was provided with a call to setDocumentXmpMetadata. It will not + return the default metadata. + + \sa setDocumentXmpMetadata() +*/ + +QByteArray QPdfWriter::documentXmpMetadata() const +{ + Q_D(const QPdfWriter); + return d->engine->documentXmpMetadata(); +} + +/*! + \since 5.15 + + Adds \a fileName attachment to the PDF with (optional) \a mimeType + \a data contains the raw file data to embed into the PDF file. +*/ + +void QPdfWriter::addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType) +{ + Q_D(QPdfWriter); + d->engine->addFileAttachment(fileName, data, mimeType); +} + // Defined in QPagedPaintDevice but non-virtual, add QPdfWriter specific doc here #ifdef Q_QDOC /*! diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index 668081e008..04039a0104 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -75,6 +75,11 @@ public: void setResolution(int resolution); int resolution() const; + void setDocumentXmpMetadata(const QByteArray &xmpMetadata); + QByteArray documentXmpMetadata() const; + + void addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType = QString()); + #ifdef Q_QDOC bool setPageLayout(const QPageLayout &pageLayout); bool setPageSize(const QPageSize &pageSize); -- cgit v1.2.3 From a1f4321bbba2f3bff24d753ce766be738dbfa61a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 3 Dec 2019 15:12:51 +0100 Subject: QTextDocument: Give fontFamily() precedence over fontFamilies() If the singular fontFamily() is given, then this is obviously the one to be preferred over any plural fontFamilies(). Make sure it always ends up first in the list of emitted font families. Change-Id: I1e3b1ba29721c8298b1a0d4a1e1da49ba5b4e7ac Fixes: QTBUG-80475 Reviewed-by: Lars Knoll --- src/gui/text/qtextdocument.cpp | 39 ++++++++++++++------------------------- src/gui/text/qtextdocument_p.h | 1 - 2 files changed, 14 insertions(+), 26 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 4b35509ace..25c153910d 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2297,6 +2297,17 @@ QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc) defaultCharFormat.clearProperty(QTextFormat::TextUnderlineStyle); } +static QStringList resolvedFontFamilies(const QTextCharFormat &format) +{ + QStringList fontFamilies = format.fontFamilies().toStringList(); + const QString mainFontFamily = format.fontFamily(); + if (!mainFontFamily.isEmpty() && !fontFamilies.startsWith(mainFontFamily)) { + fontFamilies.removeAll(mainFontFamily); + fontFamilies.prepend(mainFontFamily); + } + return fontFamilies; +} + /*! Returns the document in HTML format. The conversion may not be perfect, especially for complex documents, due to the limitations @@ -2325,11 +2336,7 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) if (mode == ExportEntireDocument) { html += QLatin1String(" style=\""); - QStringList fontFamilies = defaultCharFormat.fontFamilies().toStringList(); - if (!fontFamilies.isEmpty()) - emitFontFamily(fontFamilies); - else - emitFontFamily(defaultCharFormat.fontFamily()); + emitFontFamily(resolvedFontFamilies(defaultCharFormat)); if (defaultCharFormat.hasProperty(QTextFormat::FontPointSize)) { html += QLatin1String(" font-size:"); @@ -2391,14 +2398,10 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) bool attributesEmitted = false; { - const QStringList families = format.fontFamilies().toStringList(); - const QString family = format.fontFamily(); - if (!families.isEmpty() && families != defaultCharFormat.fontFamilies().toStringList()) { + const QStringList families = resolvedFontFamilies(format); + if (!families.isEmpty() && families != resolvedFontFamilies(defaultCharFormat)) { emitFontFamily(families); attributesEmitted = true; - } else if (!family.isEmpty() && family != defaultCharFormat.fontFamily()) { - emitFontFamily(family); - attributesEmitted = true; } } @@ -2661,20 +2664,6 @@ void QTextHtmlExporter::emitPageBreakPolicy(QTextFormat::PageBreakFlags policy) html += QLatin1String(" page-break-after:always;"); } -void QTextHtmlExporter::emitFontFamily(const QString &family) -{ - html += QLatin1String(" font-family:"); - - QLatin1String quote("\'"); - if (family.contains(QLatin1Char('\''))) - quote = QLatin1String("""); - - html += quote; - html += family.toHtmlEscaped(); - html += quote; - html += QLatin1Char(';'); -} - void QTextHtmlExporter::emitFontFamily(const QStringList &families) { html += QLatin1String(" font-family:"); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index f4e7a25f22..40252c93eb 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -396,7 +396,6 @@ private: void emitBorderStyle(QTextFrameFormat::BorderStyle style); void emitPageBreakPolicy(QTextFormat::PageBreakFlags policy); - void emitFontFamily(const QString &family); void emitFontFamily(const QStringList &families); void emitBackgroundAttribute(const QTextFormat &format); -- cgit v1.2.3 From 045250ed4258932d7fbc13cdad163db1cd64dca7 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Fri, 22 Nov 2019 14:26:12 +0100 Subject: Fix QPalette::isBrushSet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous implementation did not take into account different color groups in resolve mask. It led to some issues when resolving a palette or checking whether a brush is set or not. Task-number: QTBUG-78544 Change-Id: I9b67b2c444eb62c022643022a874dc400005e6ee Reviewed-by: Tor Arne Vestbø Reviewed-by: Shawn Rutledge --- src/gui/kernel/qpalette.cpp | 97 +++++++++++++++++++++++++++++++++------------ src/gui/kernel/qpalette.h | 24 +++++------ 2 files changed, 82 insertions(+), 39 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index fdcdef4345..44efad5910 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -48,6 +48,22 @@ QT_BEGIN_NAMESPACE static int qt_palette_count = 1; +static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup) +{ + return QPalette::NColorRoles * colorGroup; +} + +static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup, + QPalette::ColorRole colorRole) +{ + return colorRole + colorRoleOffset(colorGroup); +} + +Q_STATIC_ASSERT_X(bitPosition(QPalette::ColorGroup(QPalette::NColorGroups - 1), + QPalette::ColorRole(QPalette::NColorRoles - 1)) + < sizeof(QPalette::ResolveMask) * CHAR_BIT, + "The resolve mask type is not wide enough to fit the entire bit mask."); + class QPalettePrivate { public: QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { } @@ -535,8 +551,6 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button) QPalette::QPalette() : d(nullptr) { - data.current_group = Active; - data.resolve_mask = 0; // Initialize to application palette if present, else default to black. // This makes it possible to instantiate QPalette outside QGuiApplication, // for example in the platform plugins. @@ -546,7 +560,7 @@ QPalette::QPalette() } else { init(); qt_palette_from_color(*this, Qt::black); - data.resolve_mask = 0; + data.resolveMask = 0; } } @@ -678,8 +692,6 @@ QPalette::~QPalette() /*!\internal*/ void QPalette::init() { d = new QPalettePrivate; - data.resolve_mask = 0; - data.current_group = Active; //as a default.. } /*! @@ -736,7 +748,7 @@ const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const Q_ASSERT(cr < NColorRoles); if(gr >= (int)NColorGroups) { if(gr == Current) { - gr = (ColorGroup)data.current_group; + gr = data.currentGroup; } else { qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr); gr = Active; @@ -774,7 +786,7 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) } if (cg == Current) { - cg = ColorGroup(data.current_group); + cg = data.currentGroup; } else if (cg >= NColorGroups) { qWarning("QPalette::setBrush: Unknown ColorGroup: %d", cg); cg = Active; @@ -784,7 +796,8 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) detach(); d->br[cg][cr] = b; } - data.resolve_mask |= (1<= NColorGroups) { + qWarning() << "Wrong color group:" << cg; + return false; + } + + if (cr >= NColorRoles) { + qWarning() << "Wrong color role:" << cr; + return false; + } + + return data.resolveMask & (ResolveMask(1) << bitPosition(cg, cr)); } /*! @@ -863,7 +894,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) { if(group1 >= (int)NColorGroups) { if(group1 == Current) { - group1 = (ColorGroup)data.current_group; + group1 = data.currentGroup; } else { qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1); group1 = Active; @@ -871,7 +902,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) } if(group2 >= (int)NColorGroups) { if(group2 == Current) { - group2 = (ColorGroup)data.current_group; + group2 = data.currentGroup; } else { qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2); group2 = Active; @@ -922,21 +953,25 @@ qint64 QPalette::cacheKey() const */ QPalette QPalette::resolve(const QPalette &other) const { - if ((*this == other && data.resolve_mask == other.data.resolve_mask) - || data.resolve_mask == 0) { + if ((*this == other && data.resolveMask == other.data.resolveMask) + || data.resolveMask == 0) { QPalette o = other; - o.data.resolve_mask = data.resolve_mask; + o.data.resolveMask = data.resolveMask; return o; } QPalette palette(*this); palette.detach(); - for(int role = 0; role < (int)NColorRoles; role++) - if (!(data.resolve_mask & (1<br[grp][role] = other.d->br[grp][role]; - palette.data.resolve_mask |= other.data.resolve_mask; + } + } + } + + palette.data.resolveMask |= other.data.resolveMask; return palette; } @@ -947,7 +982,12 @@ QPalette QPalette::resolve(const QPalette &other) const */ /*! - \fn void QPalette::resolve(uint mask) + \typedef ResolveMaskType + \internal + */ + +/*! + \fn void QPalette::resolve(ResolveMaskType mask) \internal */ @@ -1081,10 +1121,15 @@ void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBru QBrush(Qt::blue), QBrush(Qt::magenta), QBrush(toolTipBase), QBrush(toolTipText)); - data.resolve_mask &= ~(1 << Highlight); - data.resolve_mask &= ~(1 << HighlightedText); - data.resolve_mask &= ~(1 << LinkVisited); - data.resolve_mask &= ~(1 << Link); + for (int cr = Highlight; cr <= LinkVisited; ++cr) { + if (cg == All) { + for (int group = Active; group < NColorGroups; ++group) { + data.resolveMask &= ~(ResolveMask(1) << bitPosition(ColorGroup(group), ColorRole(cr))); + } + } else { + data.resolveMask &= ~(ResolveMask(1) << bitPosition(ColorGroup(cg), ColorRole(cr))); + } + } } @@ -1189,7 +1234,7 @@ QDebug operator<<(QDebug dbg, const QPalette &p) "ToolTipBase","ToolTipText", "PlaceholderText" }; QDebugStateSaver saver(dbg); QDebug nospace = dbg.nospace(); - const uint mask = p.resolve(); + auto mask = p.resolve(); nospace << "QPalette(resolve=" << Qt::hex << Qt::showbase << mask << ','; for (int role = 0; role < (int)QPalette::NColorRoles; ++role) { if (mask & (1<(data.current_group); } - inline void setCurrentColorGroup(ColorGroup cg) { data.current_group = cg; } + inline ColorGroup currentColorGroup() const { return data.currentGroup; } + inline void setCurrentColorGroup(ColorGroup cg) { data.currentGroup = cg; } inline const QColor &color(ColorGroup cg, ColorRole cr) const { return brush(cg, cr).color(); } @@ -158,9 +156,11 @@ public: #endif qint64 cacheKey() const; - QPalette resolve(const QPalette &) const; - inline uint resolve() const { return data.resolve_mask; } - inline void resolve(uint mask) { data.resolve_mask = mask; } + QPalette resolve(const QPalette &other) const; + + using ResolveMask = quint64; + inline ResolveMask resolve() const { return data.resolveMask; } + inline void resolve(ResolveMask mask) { data.resolveMask = mask; } private: void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button, @@ -185,13 +185,11 @@ private: QPalettePrivate *d; struct Data { - uint current_group : 4; - uint resolve_mask : 28; - }; - union { - Data data; - quint32 for_faster_swapping_dont_use; + ResolveMask resolveMask{0}; + ColorGroup currentGroup{Active}; }; + Data data; + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p); }; -- cgit v1.2.3 From 4d8ee1b3493b79a6f1cd5200e6102711c0102c9e Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Fri, 22 Nov 2019 15:23:51 +0100 Subject: QPalette: fix debug stream operator Current implementation takes both color group and color role into account. Code readability is also improved. Fixes: QTBUG-78544 Change-Id: Ibfa925f3e4cb0be89915607eee142926e05000b5 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qpalette.cpp | 76 +++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 26 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 44efad5910..e31ce00e14 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -44,6 +44,8 @@ #include "qvariant.h" #include "qdebug.h" +#include + QT_BEGIN_NAMESPACE static int qt_palette_count = 1; @@ -1224,36 +1226,58 @@ Q_GUI_EXPORT QPalette qt_fusionPalette() } #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QPalette &p) +static QString groupsToString(const QPalette &p, QPalette::ColorRole cr) { - const char *colorGroupNames[] = {"Active", "Disabled", "Inactive"}; - const char *colorRoleNames[] = - {"WindowText", "Button", "Light", "Midlight", "Dark", "Mid", "Text", - "BrightText", "ButtonText", "Base", "Window", "Shadow", "Highlight", - "HighlightedText", "Link", "LinkVisited", "AlternateBase", "NoRole", - "ToolTipBase","ToolTipText", "PlaceholderText" }; - QDebugStateSaver saver(dbg); - QDebug nospace = dbg.nospace(); - auto mask = p.resolve(); - nospace << "QPalette(resolve=" << Qt::hex << Qt::showbase << mask << ','; - for (int role = 0; role < (int)QPalette::NColorRoles; ++role) { - if (mask & (1<(group), - static_cast(role)).rgba(); - nospace << colorGroupNames[group] << ':' << color; - } - nospace << ']'; + const auto groupEnum = QMetaEnum::fromType(); + + QString groupString; + for (int group = 0; group < QPalette::NColorGroups; ++group) { + const auto cg = QPalette::ColorGroup(group); + + if (p.isBrushSet(cg, cr)) { + const auto &color = p.color(cg, cr); + groupString += QString::fromUtf8(groupEnum.valueToKey(cg)) + QLatin1Char(':') + + color.name(QColor::HexArgb) + QLatin1Char(','); } } - nospace << ')' << Qt::noshowbase << Qt::dec; - return dbg; + groupString.chop(1); + + return groupString; +} + +static QString rolesToString(const QPalette &p) +{ + const auto roleEnum = QMetaEnum::fromType(); + + QString roleString; + for (int role = 0; role < QPalette::NColorRoles; ++role) { + const auto cr = QPalette::ColorRole(role); + + auto groupString = groupsToString(p, cr); + if (!groupString.isEmpty()) + roleString += QString::fromUtf8(roleEnum.valueToKey(cr)) + QStringLiteral(":[") + + groupString + QStringLiteral("],"); + } + roleString.chop(1); + + return roleString; } + +QDebug operator<<(QDebug dbg, const QPalette &p) +{ + QDebugStateSaver saver(dbg); + dbg.nospace(); + + dbg << "QPalette(resolve=" << Qt::hex << Qt::showbase << p.resolve(); + + auto roleString = rolesToString(p); + if (!roleString.isEmpty()) + dbg << ',' << roleString; + + dbg << ')'; + + return dbg; + } #endif QT_END_NAMESPACE -- cgit v1.2.3 From d593c5865acb544d02e45ac24245d9bc9988ffb1 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 12 Dec 2019 14:06:31 +0100 Subject: Remove QOpenGLTexture dependency from QTextureFileData Just print the hex value of the format. Task-number: QTBUG-74409 Change-Id: I0441eda050735325f7686532b17ef765f71bec9b Reviewed-by: Paul Olav Tvete --- src/gui/util/qtexturefiledata.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/gui') diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index 41cbd1b15a..3c8130c229 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -38,11 +38,7 @@ ****************************************************************************/ #include "qtexturefiledata_p.h" -#include #include -#if QT_CONFIG(opengl) -#include -#endif QT_BEGIN_NAMESPACE @@ -247,13 +243,7 @@ void QTextureFileData::setLogName(const QByteArray &name) static QByteArray glFormatName(quint32 fmt) { - const char *id = nullptr; -#if QT_CONFIG(opengl) - id = QMetaEnum::fromType().valueToKey(fmt); -#endif - QByteArray res(id ? id : "(?)"); - res += " [0x" + QByteArray::number(fmt, 16).rightJustified(4, '0') + ']'; - return res; + return QByteArray("0x" + QByteArray::number(fmt, 16).rightJustified(4, '0')); } QDebug operator<<(QDebug dbg, const QTextureFileData &d) -- cgit v1.2.3 From 2c3eaa7b87219d24facfe81a5b22cb218324f1ae Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 27 Dec 2019 18:01:49 +0100 Subject: Fix semi-transparent text on Linux with subpixel anti-aliasing The newly optimized rgbBlend function wasn't updated to handle SourceOver compositing when dealing with semi-transparent text color. The extra composition isn't SIMD optimized but short-cut for all opaque colors. Fixes: QTBUG-80982 Change-Id: I88c1e60fd5e80a8c7f9e6b0e7de8248c7c00ebc2 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qdrawhelper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index e8d129d047..f8d5914f37 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6048,7 +6048,11 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba // Give up and do a naive gray alphablend. Needed to deal with ARGB32 and invalid ARGB32_premultiplied, see QTBUG-60571 blend_pixel(*dst, src, qRgbAvg(coverage)); } else if (!colorProfile) { - *dst = rgbBlend(*dst, src, coverage); + // First do naive blend with text-color + QRgb s = *dst; + blend_pixel(s, src); + // Then a naive blend with glyph shape + *dst = rgbBlend(*dst, s, coverage); } else if (srcLinear.isOpaque()) { rgbBlendPixel(dst, coverage, srcLinear, colorProfile); } else { -- cgit v1.2.3 From aa542be4e005b1feedc2e17fd6ca2387bf2fea1b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Dec 2019 17:23:50 +0100 Subject: Modernize setAlphaChannel(), and deprecated alphaChannel() The two methods have been marked obsolete for a very long time, setAlphaChannel() is still convenient though, so this patch modernizes it and removes obsolete from the API, while marking QImage::alphaChannel() as deprecated. They don't work as getter and setter anyway, since setAlphaChannel() actually does an alpha composition. Change-Id: I634d6463f78c42bb9c5fa3df17500ec01bfcac33 Reviewed-by: Eirik Aavitsland --- src/gui/image/qimage.cpp | 95 +++++++++++++++--------------------------------- src/gui/image/qimage.h | 4 +- 2 files changed, 32 insertions(+), 67 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 99d64737c5..3ddc52bed4 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4410,99 +4410,61 @@ bool QImage::isDetached() const /*! - \obsolete Sets the alpha channel of this image to the given \a alphaChannel. - If \a alphaChannel is an 8 bit grayscale image, the intensity values are - written into this buffer directly. Otherwise, \a alphaChannel is converted - to 32 bit and the intensity of the RGB pixel values is used. - - Note that the image will be converted to the Format_ARGB32_Premultiplied - format if the function succeeds. + If \a alphaChannel is an 8 bit alpha image, the alpha values are + used directly. Otherwise, \a alphaChannel is converted to 8 bit + grayscale and the intensity of the pixel values is used. - Use one of the composition modes in QPainter::CompositionMode instead. + If the image already has an alpha channel, the existing alpha channel + is multiplied with the new one. If the image doesn't have an alpha + channel it will be converted to a format that does. - \warning This function is expensive. + The operation is similar to painting \a alphaChannel as an alpha image + over this image using \c QPainter::CompositionMode_DestinationIn. - \sa alphaChannel(), {QImage#Image Transformations}{Image - Transformations}, {QImage#Image Formats}{Image Formats} + \sa hasAlphaChannel(), alphaChannel(), + {QImage#Image Transformations}{Image Transformations}, + {QImage#Image Formats}{Image Formats} */ void QImage::setAlphaChannel(const QImage &alphaChannel) { - if (!d) + if (!d || alphaChannel.isNull()) return; - int w = d->width; - int h = d->height; - - if (w != alphaChannel.d->width || h != alphaChannel.d->height) { - qWarning("QImage::setAlphaChannel: " - "Alpha channel must have same dimensions as the target image"); - return; - } - if (d->paintEngine && d->paintEngine->isActive()) { qWarning("QImage::setAlphaChannel: " "Unable to set alpha channel while image is being painted on"); return; } - if (d->format == QImage::Format_ARGB32_Premultiplied) + const Format alphaFormat = qt_alphaVersionForPainting(d->format); + if (d->format == alphaFormat) detach(); else - *this = convertToFormat(QImage::Format_ARGB32_Premultiplied); + convertTo(alphaFormat); if (isNull()) return; - // Slight optimization since alphachannels are returned as 8-bit grays. - if (alphaChannel.format() == QImage::Format_Alpha8 ||( alphaChannel.d->depth == 8 && alphaChannel.isGrayscale())) { - const uchar *src_data = alphaChannel.d->data; - uchar *dest_data = d->data; - for (int y=0; ybytes_per_line; - dest_data += d->bytes_per_line; - } + QImage sourceImage; + if (alphaChannel.format() == QImage::Format_Alpha8 || (alphaChannel.d->depth == 8 && alphaChannel.isGrayscale())) + sourceImage = alphaChannel; + else + sourceImage = alphaChannel.convertToFormat(QImage::Format_Grayscale8); + if (!sourceImage.reinterpretAsFormat(QImage::Format_Alpha8)) + return; - } else { - const QImage sourceImage = alphaChannel.convertToFormat(QImage::Format_RGB32); - if (sourceImage.isNull()) - return; - const uchar *src_data = sourceImage.d->data; - uchar *dest_data = d->data; - for (int y=0; ybytes_per_line; - dest_data += d->bytes_per_line; - } - } + QPainter painter(this); + if (sourceImage.size() != size()) + painter.setRenderHint(QPainter::SmoothPixmapTransform); + painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + painter.drawImage(rect(), sourceImage); } +#if QT_DEPRECATED_SINCE(5, 15) /*! \obsolete @@ -4592,6 +4554,7 @@ QImage QImage::alphaChannel() const return image; } +#endif /*! Returns \c true if the image has a format that respects the alpha diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 7544ccca05..115071c16e 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -266,7 +266,9 @@ public: bool hasAlphaChannel() const; void setAlphaChannel(const QImage &alphaChannel); - QImage alphaChannel() const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED QImage alphaChannel() const; +#endif QImage createAlphaMask(Qt::ImageConversionFlags flags = Qt::AutoColor) const; #ifndef QT_NO_IMAGE_HEURISTIC_MASK QImage createHeuristicMask(bool clipTight = true) const; -- cgit v1.2.3 From 6b835d5e51bafe93090286fa2acb36f3d5d8f719 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 3 Jan 2020 09:13:34 +0100 Subject: QTextDocument: Set the font family to be after the families set This amends a1f4321bbba2f3bff24d753ce766be738dbfa61a as the font families should take precedence over the font family set. If the font family is already included in the families then it should keep its placement. Otherwise it should be appended. Task-number: QTBUG-80475 Change-Id: I0049189c88b6879e57619815ec780960e9c0a300 Reviewed-by: Ulf Hermann Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextdocument.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 25c153910d..1353568ec1 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2301,10 +2301,8 @@ static QStringList resolvedFontFamilies(const QTextCharFormat &format) { QStringList fontFamilies = format.fontFamilies().toStringList(); const QString mainFontFamily = format.fontFamily(); - if (!mainFontFamily.isEmpty() && !fontFamilies.startsWith(mainFontFamily)) { - fontFamilies.removeAll(mainFontFamily); - fontFamilies.prepend(mainFontFamily); - } + if (!mainFontFamily.isEmpty() && !fontFamilies.contains(mainFontFamily)) + fontFamilies.append(mainFontFamily); return fontFamilies; } -- cgit v1.2.3 From 908df199d0782d161e83d75dd7a7d9aab29ff9e7 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 13 Dec 2019 14:18:11 +0100 Subject: Add environment variables for customizing Vulkan QT_VULKAN_INSTANCE_EXTENSIONS to specify additional instance extensions. QT_VULKAN_INSTANCE_LAYERS to specify additional instance layers. QT_VULKAN_DEVICE_EXTENSIONS to specify additional device extensions. These will apply to all QVulkanWindows and everything that uses RHI, including Qt Quick with the Vulkan RHI backend. Task-number: QTBUG-80499 Change-Id: I912495affa987d62a9823d55d06d6a8209f6adc6 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhivulkan.cpp | 11 +++++++++++ src/gui/vulkan/qvulkanwindow.cpp | 9 +++++++++ 2 files changed, 20 insertions(+) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 21ae142b1d..c540e9fa85 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -501,6 +501,17 @@ bool QRhiVulkan::create(QRhi::Flags flags) } } + QByteArrayList envExtList; + if (qEnvironmentVariableIsSet("QT_VULKAN_DEVICE_EXTENSIONS")) { + envExtList = qgetenv("QT_VULKAN_DEVICE_EXTENSIONS").split(';'); + for (auto ext : requestedDevExts) + envExtList.removeAll(ext); + for (const QByteArray &ext : envExtList) { + if (!ext.isEmpty()) + requestedDevExts.append(ext.constData()); + } + } + VkDeviceCreateInfo devInfo; memset(&devInfo, 0, sizeof(devInfo)); devInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp index ed73a77683..e211863f21 100644 --- a/src/gui/vulkan/qvulkanwindow.cpp +++ b/src/gui/vulkan/qvulkanwindow.cpp @@ -689,6 +689,15 @@ void QVulkanWindowPrivate::init() QVulkanInfoVector supportedExtensions = q->supportedDeviceExtensions(); QByteArrayList reqExts = requestedDevExtensions; reqExts.append("VK_KHR_swapchain"); + + QByteArray envExts = qgetenv("QT_VULKAN_DEVICE_EXTENSIONS"); + if (!envExts.isEmpty()) { + QByteArrayList envExtList = envExts.split(';'); + for (auto ext : reqExts) + envExtList.removeAll(ext); + reqExts.append(envExtList); + } + for (const QByteArray &ext : reqExts) { if (supportedExtensions.contains(ext)) devExts.append(ext.constData()); -- cgit v1.2.3 From 844ef184e8021237280a45ead04a3ab39cefa657 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 17 Dec 2019 15:15:24 +0100 Subject: RHI: Remove old native texture API Task-number: QTBUG-78570 Change-Id: I8c4850828ac03319ac923a26c2e985883956c286 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhi.cpp | 44 -------------------------------------- src/gui/rhi/qrhi_p.h | 2 -- src/gui/rhi/qrhid3d11.cpp | 43 +------------------------------------ src/gui/rhi/qrhid3d11_p.h | 5 ----- src/gui/rhi/qrhid3d11_p_p.h | 3 --- src/gui/rhi/qrhigles2.cpp | 41 +---------------------------------- src/gui/rhi/qrhigles2_p.h | 5 ----- src/gui/rhi/qrhigles2_p_p.h | 4 +--- src/gui/rhi/qrhimetal.mm | 43 +------------------------------------ src/gui/rhi/qrhimetal_p.h | 5 ----- src/gui/rhi/qrhimetal_p_p.h | 3 --- src/gui/rhi/qrhinull.cpp | 22 ++----------------- src/gui/rhi/qrhinull_p.h | 4 ---- src/gui/rhi/qrhinull_p_p.h | 3 --- src/gui/rhi/qrhivulkan.cpp | 51 +------------------------------------------- src/gui/rhi/qrhivulkan_p.h | 6 ------ src/gui/rhi/qrhivulkan_p_p.h | 3 --- 17 files changed, 7 insertions(+), 280 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 58f30deb41..00d4df53bd 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2214,20 +2214,6 @@ QRhiResource::Type QRhiTexture::resourceType() const Regardless of the return value, calling release() is always safe. */ -/*! - \return a pointer to a backend-specific QRhiNativeHandles subclass, such as - QRhiVulkanTextureNativeHandles. The returned value is null when exposing - the underlying native resources is not supported by the backend. - - \sa QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, - QRhiMetalTextureNativeHandles, QRhiGles2TextureNativeHandles - */ -// TODO: remove this version once QtQuick has stopped using it -const QRhiNativeHandles *QRhiTexture::nativeHandles() -{ - return nullptr; -} - /*! \return the underlying native resources for this texture. The returned value will be empty if exposing the underlying native resources is not supported by @@ -2240,36 +2226,6 @@ QRhiTexture::NativeTexture QRhiTexture::nativeTexture() return {}; } -/*! - Similar to build() except that no new native textures are created. Instead, - the texture from \a src is used. - - This allows importing an existing native texture object (which must belong - to the same device or sharing context, depending on the graphics API) from - an external graphics engine. - - \note format(), pixelSize(), sampleCount(), and flags() must still be set - correctly. Passing incorrect sizes and other values to QRhi::newTexture() - and then following it with a buildFrom() expecting that the native texture - object alone is sufficient to deduce such values is \b wrong and will lead - to problems. - - \note QRhiTexture does not take ownership of the texture object. release() - does not free the object or any associated memory. - - The opposite of this operation, exposing a QRhiTexture-created native - texture object to a foreign engine, is possible via nativeHandles(). - - \sa QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, - QRhiMetalTextureNativeHandles, QRhiGles2TextureNativeHandles - */ -// TODO: remove this version once QtQuick has stopped using it -bool QRhiTexture::buildFrom(const QRhiNativeHandles *src) -{ - Q_UNUSED(src); - return false; -} - /*! Similar to build() except that no new native textures are created. Instead, the native texture resources specified by \a src is used. diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 44118b2f10..a6c65aac5e 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -780,9 +780,7 @@ public: void setSampleCount(int s) { m_sampleCount = s; } virtual bool build() = 0; - virtual const QRhiNativeHandles *nativeHandles(); virtual NativeTexture nativeTexture(); - virtual bool buildFrom(const QRhiNativeHandles *src); virtual bool buildFrom(NativeTexture src); protected: diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index ba2488bffb..c5923fe411 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -108,17 +108,6 @@ QT_BEGIN_NAMESPACE \c{ID3D11Device *} and \c{ID3D11DeviceContext *}. */ -/*! - \class QRhiD3D11TextureNativeHandles - \internal - \inmodule QtGui - \brief Holds the D3D texture object that is backing a QRhiTexture instance. - - \note The class uses \c{void *} as the type since including the COM-based - \c{d3d11.h} headers is not acceptable here. The actual type is - \c{ID3D11Texture2D *}. - */ - // help mingw with its ancient sdk headers #ifndef DXGI_ADAPTER_FLAG_SOFTWARE #define DXGI_ADAPTER_FLAG_SOFTWARE 2 @@ -2674,8 +2663,6 @@ bool QD3D11Texture::finishBuild() return false; } - nativeHandlesStruct.texture = tex; - generation += 1; return true; } @@ -2741,29 +2728,6 @@ bool QD3D11Texture::build() return true; } -bool QD3D11Texture::buildFrom(const QRhiNativeHandles *src) -{ - const QRhiD3D11TextureNativeHandles *h = static_cast(src); - if (!h || !h->texture) - return false; - - if (!prepareBuild()) - return false; - - tex = static_cast(h->texture); - - if (!finishBuild()) - return false; - - QRHI_PROF; - QRHI_PROF_F(newTexture(this, false, int(mipLevelCount), m_flags.testFlag(CubeMap) ? 6 : 1, int(sampleDesc.Count))); - - owns = false; - QRHI_RES_RHI(QRhiD3D11); - rhiD->registerResource(this); - return true; -} - bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) { auto *srcTex = static_cast(src.object); @@ -2787,14 +2751,9 @@ bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) return true; } -const QRhiNativeHandles *QD3D11Texture::nativeHandles() -{ - return &nativeHandlesStruct; -} - QRhiTexture::NativeTexture QD3D11Texture::nativeTexture() { - return {&nativeHandlesStruct.texture, 0}; + return {&tex, 0}; } ID3D11UnorderedAccessView *QD3D11Texture::unorderedAccessViewForLevel(int level) diff --git a/src/gui/rhi/qrhid3d11_p.h b/src/gui/rhi/qrhid3d11_p.h index 5df1843b1e..aba0f37ee7 100644 --- a/src/gui/rhi/qrhid3d11_p.h +++ b/src/gui/rhi/qrhid3d11_p.h @@ -69,11 +69,6 @@ struct Q_GUI_EXPORT QRhiD3D11NativeHandles : public QRhiNativeHandles void *context = nullptr; }; -struct Q_GUI_EXPORT QRhiD3D11TextureNativeHandles : public QRhiNativeHandles -{ - void *texture = nullptr; // ID3D11Texture2D* -}; - QT_END_NAMESPACE #endif diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index 8f02c4300b..9ddd2aa797 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -99,9 +99,7 @@ struct QD3D11Texture : public QRhiTexture ~QD3D11Texture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); @@ -114,7 +112,6 @@ struct QD3D11Texture : public QRhiTexture DXGI_FORMAT dxgiFormat; uint mipLevelCount = 0; DXGI_SAMPLE_DESC sampleDesc; - QRhiD3D11TextureNativeHandles nativeHandlesStruct; ID3D11UnorderedAccessView *perLevelViews[QRhi::MAX_LEVELS]; uint generation = 0; friend class QRhiD3D11; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index ffaccbad71..e63ed11dd4 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -137,13 +137,6 @@ QT_BEGIN_NAMESPACE \brief Holds the OpenGL context used by the QRhi. */ -/*! - \class QRhiGles2TextureNativeHandles - \internal - \inmodule QtGui - \brief Holds the OpenGL texture object that is backing a QRhiTexture instance. - */ - #ifndef GL_BGRA #define GL_BGRA 0x80E1 #endif @@ -3324,7 +3317,6 @@ void QGles2Texture::release() texture = 0; specified = false; - nativeHandlesStruct.texture = 0; QRHI_RES_RHI(QRhiGles2); if (owns) @@ -3483,31 +3475,6 @@ bool QGles2Texture::build() QRHI_PROF_F(newTexture(this, true, mipLevelCount, isCube ? 6 : 1, 1)); owns = true; - nativeHandlesStruct.texture = texture; - - generation += 1; - rhiD->registerResource(this); - return true; -} - -bool QGles2Texture::buildFrom(const QRhiNativeHandles *src) -{ - const QRhiGles2TextureNativeHandles *h = static_cast(src); - if (!h || !h->texture) - return false; - - if (!prepareBuild()) - return false; - - texture = h->texture; - specified = true; - - QRHI_RES_RHI(QRhiGles2); - QRHI_PROF; - QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, 1)); - - owns = false; - nativeHandlesStruct.texture = texture; generation += 1; rhiD->registerResource(this); @@ -3531,21 +3498,15 @@ bool QGles2Texture::buildFrom(QRhiTexture::NativeTexture src) QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, 1)); owns = false; - nativeHandlesStruct.texture = texture; generation += 1; rhiD->registerResource(this); return true; } -const QRhiNativeHandles *QGles2Texture::nativeHandles() -{ - return &nativeHandlesStruct; -} - QRhiTexture::NativeTexture QGles2Texture::nativeTexture() { - return {&nativeHandlesStruct.texture, 0}; + return {&texture, 0}; } QGles2Sampler::QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, diff --git a/src/gui/rhi/qrhigles2_p.h b/src/gui/rhi/qrhigles2_p.h index 7f7c8b4c40..8d8f0c7396 100644 --- a/src/gui/rhi/qrhigles2_p.h +++ b/src/gui/rhi/qrhigles2_p.h @@ -74,11 +74,6 @@ struct Q_GUI_EXPORT QRhiGles2NativeHandles : public QRhiNativeHandles QOpenGLContext *context = nullptr; }; -struct Q_GUI_EXPORT QRhiGles2TextureNativeHandles : public QRhiNativeHandles -{ - uint texture = 0; -}; - QT_END_NAMESPACE #endif diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index d4f1336c3e..a9b3022612 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -132,9 +132,7 @@ struct QGles2Texture : public QRhiTexture ~QGles2Texture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); @@ -149,7 +147,7 @@ struct QGles2Texture : public QRhiTexture QGles2SamplerData samplerState; bool specified = false; int mipLevelCount = 0; - QRhiGles2TextureNativeHandles nativeHandlesStruct; + enum Access { AccessNone, AccessSample, diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index b6ca40e08b..222bf170dc 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -113,15 +113,6 @@ QT_BEGIN_NAMESPACE \c{id}. */ -/*! - \class QRhiMetalTextureNativeHandles - \inmodule QtRhi - \brief Holds the Metal texture object that is backing a QRhiTexture instance. - - \note The class uses \c{void *} as the type since including the Objective C - headers is not acceptable here. The actual type is \c{id}. - */ - /*! \class QRhiMetalCommandBufferNativeHandles \inmodule QtRhi @@ -2296,7 +2287,6 @@ void QMetalTexture::release() e.texture.texture = d->owns ? d->tex : nil; d->tex = nil; - nativeHandlesStruct.texture = nullptr; for (int i = 0; i < QMTL_FRAMES_IN_FLIGHT; ++i) { e.texture.stagingBuffers[i] = d->stagingBuf[i]; @@ -2508,7 +2498,6 @@ bool QMetalTexture::build() d->tex.label = [NSString stringWithUTF8String: m_objectName.constData()]; d->owns = true; - nativeHandlesStruct.texture = d->tex; QRHI_PROF; QRHI_PROF_F(newTexture(this, true, mipLevelCount, isCube ? 6 : 1, samples)); @@ -2519,30 +2508,6 @@ bool QMetalTexture::build() return true; } -bool QMetalTexture::buildFrom(const QRhiNativeHandles *src) -{ - const QRhiMetalTextureNativeHandles *h = static_cast(src); - if (!h || !h->texture) - return false; - - if (!prepareBuild()) - return false; - - d->tex = (id) h->texture; - - d->owns = false; - nativeHandlesStruct.texture = d->tex; - - QRHI_PROF; - QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, samples)); - - lastActiveFrameSlot = -1; - generation += 1; - QRHI_RES_RHI(QRhiMetal); - rhiD->registerResource(this); - return true; -} - bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src) { void * const * tex = (void * const *) src.object; @@ -2555,7 +2520,6 @@ bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src) d->tex = (id) *tex; d->owns = false; - nativeHandlesStruct.texture = d->tex; QRHI_PROF; QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, samples)); @@ -2567,14 +2531,9 @@ bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src) return true; } -const QRhiNativeHandles *QMetalTexture::nativeHandles() -{ - return &nativeHandlesStruct; -} - QRhiTexture::NativeTexture QMetalTexture::nativeTexture() { - return {&nativeHandlesStruct.texture, 0}; + return {&d->tex, 0}; } id QMetalTextureData::viewForLevel(int level) diff --git a/src/gui/rhi/qrhimetal_p.h b/src/gui/rhi/qrhimetal_p.h index 094801c58c..17e28b2c0f 100644 --- a/src/gui/rhi/qrhimetal_p.h +++ b/src/gui/rhi/qrhimetal_p.h @@ -64,11 +64,6 @@ struct Q_GUI_EXPORT QRhiMetalNativeHandles : public QRhiNativeHandles void *cmdQueue = nullptr; // id }; -struct Q_GUI_EXPORT QRhiMetalTextureNativeHandles : public QRhiNativeHandles -{ - void *texture = nullptr; // id -}; - struct Q_GUI_EXPORT QRhiMetalCommandBufferNativeHandles : public QRhiNativeHandles { void *commandBuffer = nullptr; // id diff --git a/src/gui/rhi/qrhimetal_p_p.h b/src/gui/rhi/qrhimetal_p_p.h index 8e655fd98b..71d4325b1a 100644 --- a/src/gui/rhi/qrhimetal_p_p.h +++ b/src/gui/rhi/qrhimetal_p_p.h @@ -100,15 +100,12 @@ struct QMetalTexture : public QRhiTexture ~QMetalTexture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); QMetalTextureData *d; - QRhiMetalTextureNativeHandles nativeHandlesStruct; int mipLevelCount = 0; int samples = 1; uint generation = 0; diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index 80f004e049..ea67f80138 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -67,13 +67,6 @@ QT_BEGIN_NAMESPACE \brief Empty. */ -/*! - \class QRhiNullTextureNativeHandles - \internal - \inmodule QtGui - \brief Empty. - */ - QRhiNull::QRhiNull(QRhiNullInitParams *params) : offscreenCommandBuffer(this) { @@ -638,9 +631,9 @@ bool QNullTexture::build() return true; } -bool QNullTexture::buildFrom(const QRhiNativeHandles *src) +bool QNullTexture::buildFrom(QRhiTexture::NativeTexture src) { - Q_UNUSED(src); + Q_UNUSED(src) QRHI_RES_RHI(QRhiNull); const bool isCube = m_flags.testFlag(CubeMap); const bool hasMipMaps = m_flags.testFlag(MipMapped); @@ -651,17 +644,6 @@ bool QNullTexture::buildFrom(const QRhiNativeHandles *src) return true; } -bool QNullTexture::buildFrom(QRhiTexture::NativeTexture src) -{ - Q_UNUSED(src) - return buildFrom(nullptr); -} - -const QRhiNativeHandles *QNullTexture::nativeHandles() -{ - return &nativeHandlesStruct; -} - QNullSampler::QNullSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v) : QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v) diff --git a/src/gui/rhi/qrhinull_p.h b/src/gui/rhi/qrhinull_p.h index 7d3ce5dbf1..dbf385555d 100644 --- a/src/gui/rhi/qrhinull_p.h +++ b/src/gui/rhi/qrhinull_p.h @@ -60,10 +60,6 @@ struct Q_GUI_EXPORT QRhiNullNativeHandles : public QRhiNativeHandles { }; -struct Q_GUI_EXPORT QRhiNullTextureNativeHandles : public QRhiNativeHandles -{ -}; - QT_END_NAMESPACE #endif diff --git a/src/gui/rhi/qrhinull_p_p.h b/src/gui/rhi/qrhinull_p_p.h index 57c3de0418..f541fd90b8 100644 --- a/src/gui/rhi/qrhinull_p_p.h +++ b/src/gui/rhi/qrhinull_p_p.h @@ -80,11 +80,8 @@ struct QNullTexture : public QRhiTexture ~QNullTexture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; - QRhiNullTextureNativeHandles nativeHandlesStruct; QImage image[QRhi::MAX_LAYERS][QRhi::MAX_LEVELS]; }; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index c540e9fa85..c5719b54aa 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -176,21 +176,6 @@ QT_BEGIN_NAMESPACE \note Ownership of the Vulkan objects is never transferred. */ -/*! - \class QRhiVulkanTextureNativeHandles - \internal - \inmodule QtGui - \brief Holds the Vulkan image object that is backing a QRhiTexture. - - Importing and exporting Vulkan image objects that back a QRhiTexture when - running with the Vulkan backend is supported via this class. Ownership of - the Vulkan object is never transferred. - - \note Memory allocation details are not exposed. This is intentional since - memory is typically suballocated from a bigger chunk of VkDeviceMemory, and - exposing the allocator details is not desirable for now. - */ - /*! \class QRhiVulkanCommandBufferNativeHandles \internal @@ -5198,7 +5183,6 @@ void QVkTexture::release() image = VK_NULL_HANDLE; imageView = VK_NULL_HANDLE; imageAlloc = nullptr; - nativeHandlesStruct.image = VK_NULL_HANDLE; QRHI_RES_RHI(QRhiVulkan); rhiD->releaseQueue.append(e); @@ -5283,8 +5267,6 @@ bool QVkTexture::finishBuild() return false; } - nativeHandlesStruct.image = image; - lastActiveFrameSlot = -1; generation += 1; @@ -5356,31 +5338,6 @@ bool QVkTexture::build() return true; } -bool QVkTexture::buildFrom(const QRhiNativeHandles *src) -{ - const QRhiVulkanTextureNativeHandles *h = static_cast(src); - if (!h || !h->image) - return false; - - if (!prepareBuild()) - return false; - - image = h->image; - - if (!finishBuild()) - return false; - - QRHI_PROF; - QRHI_PROF_F(newTexture(this, false, int(mipLevelCount), m_flags.testFlag(CubeMap) ? 6 : 1, samples)); - - usageState.layout = h->layout; - - owns = false; - QRHI_RES_RHI(QRhiVulkan); - rhiD->registerResource(this); - return true; -} - bool QVkTexture::buildFrom(QRhiTexture::NativeTexture src) { auto *img = static_cast(src.object); @@ -5406,15 +5363,9 @@ bool QVkTexture::buildFrom(QRhiTexture::NativeTexture src) return true; } -const QRhiNativeHandles *QVkTexture::nativeHandles() -{ - nativeHandlesStruct.layout = usageState.layout; - return &nativeHandlesStruct; -} - QRhiTexture::NativeTexture QVkTexture::nativeTexture() { - return {&nativeHandlesStruct.image, usageState.layout}; + return {&image, usageState.layout}; } VkImageView QVkTexture::imageViewForLevel(int level) diff --git a/src/gui/rhi/qrhivulkan_p.h b/src/gui/rhi/qrhivulkan_p.h index ff19c7a54e..d495919671 100644 --- a/src/gui/rhi/qrhivulkan_p.h +++ b/src/gui/rhi/qrhivulkan_p.h @@ -69,12 +69,6 @@ struct Q_GUI_EXPORT QRhiVulkanNativeHandles : public QRhiNativeHandles void *vmemAllocator = nullptr; }; -struct Q_GUI_EXPORT QRhiVulkanTextureNativeHandles : public QRhiNativeHandles -{ - VkImage image = VK_NULL_HANDLE; - VkImageLayout layout = VK_IMAGE_LAYOUT_GENERAL; -}; - struct Q_GUI_EXPORT QRhiVulkanCommandBufferNativeHandles : public QRhiNativeHandles { VkCommandBuffer commandBuffer = VK_NULL_HANDLE; diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index d1b77870a1..9f18d0bf5e 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -120,9 +120,7 @@ struct QVkTexture : public QRhiTexture ~QVkTexture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); @@ -136,7 +134,6 @@ struct QVkTexture : public QRhiTexture QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT]; VkImageView perLevelImageViews[QRhi::MAX_LEVELS]; bool owns = true; - QRhiVulkanTextureNativeHandles nativeHandlesStruct; struct UsageState { // no tracking of subresource layouts (some operations can keep // subresources in different layouts for some time, but that does not -- cgit v1.2.3 From 24217594581e93b7ec3849fb56e49279c5cd3be2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 2 Jan 2020 11:33:53 +0100 Subject: Restore High DPI scale factors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the default rounding policy to "Round" so that 2 is used for 150% (144DPI) on Windows, as it was in 5.13. Fixes: QTBUG-80934 Change-Id: I0cba986ce6afc9e2737c656000ad854c07844360 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qguiapplication.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index d49f349e7a..888ccd8453 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -153,7 +153,7 @@ Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorR // that behavior by disabling rounding by default. Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; #else - Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor; + Qt::HighDpiScaleFactorRoundingPolicy::Round; #endif bool QGuiApplicationPrivate::highDpiScalingUpdated = false; @@ -3554,8 +3554,8 @@ Qt::ApplicationState QGuiApplication::applicationState() environment variable. The QGuiApplication::highDpiScaleFactorRoundingPolicy() accessor will reflect the environment, if set. - The default value is Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor. - On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThough, + The default value is Qt::HighDpiScaleFactorRoundingPolicy::Round. + On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThrough, which preserves historical behavior from earlier Qt versions. */ void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy) -- cgit v1.2.3 From c77efa6d3881554b9e593658fff80acbb8b1388d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 19 Dec 2019 21:33:10 +0100 Subject: Disable support for RasterOpModes in GL paint engine This leads to crashes for instance when displaying a text cursor in a graphics scene. Change-Id: I1b5c884ddb8325a7f5bdbc6027f0fae13f139a1c Reviewed-by: Eirik Aavitsland --- src/gui/opengl/qopenglpaintengine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 47394999c6..6c796776c0 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1330,6 +1330,7 @@ void QOpenGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stop QOpenGL2PaintEngineEx::QOpenGL2PaintEngineEx() : QPaintEngineEx(*(new QOpenGL2PaintEngineExPrivate(this))) { + gccaps &= ~QPaintEngine::RasterOpModes; } QOpenGL2PaintEngineEx::~QOpenGL2PaintEngineEx() -- cgit v1.2.3 From 0c37bc11b5f379d442ed3475483d57449b63963d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 20 Dec 2019 17:45:58 +0100 Subject: Share updates to QGuiApplicationPrivate::app_pal via helper function Change-Id: I2f582358efaadcd33b39c52317222322c589423f Reviewed-by: Simon Hausmann --- src/gui/kernel/qguiapplication.cpp | 19 ++++++++++++++----- src/gui/kernel/qguiapplication_p.h | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 888ccd8453..bdcea275c3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3293,12 +3293,8 @@ QPalette QGuiApplication::palette() */ void QGuiApplication::setPalette(const QPalette &pal) { - if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal)) + if (!QGuiApplicationPrivate::setPalette(pal)) return; - if (!QGuiApplicationPrivate::app_pal) - QGuiApplicationPrivate::app_pal = new QPalette(pal); - else - *QGuiApplicationPrivate::app_pal = pal; QCoreApplication::setAttribute(Qt::AA_SetPalette); @@ -3306,6 +3302,19 @@ void QGuiApplication::setPalette(const QPalette &pal) qGuiApp->d_func()->sendApplicationPaletteChange(); } +bool QGuiApplicationPrivate::setPalette(const QPalette &palette) +{ + if (app_pal && palette.isCopyOf(*app_pal)) + return false; + + if (!app_pal) + app_pal = new QPalette(palette); + else + *app_pal = palette; + + return true; +} + void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) { windowGeometrySpecification.applyTo(window); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 26f65b2f16..7454bba0e5 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -323,6 +323,8 @@ public: static void resetCachedDevicePixelRatio(); + static bool setPalette(const QPalette &palette); + protected: virtual void notifyThemeChanged(); virtual void sendApplicationPaletteChange(bool toAllWidgets = false, const char *className = nullptr); -- cgit v1.2.3 From 2385ab73be79e5eb69b4feb3d4c787060a56da5f Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Tue, 7 Jan 2020 13:52:11 +0200 Subject: QInputDeviceManager: initialize device counts The device counts were used before they were initialized, causing problems e.g. with mouse cursor. Fixes: QTBUG-81207 Change-Id: Ic9dadcaebeb4c4a64bb506e4236d5a9260e0fdbc Reviewed-by: Paul Wicking --- src/gui/kernel/qinputdevicemanager_p_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h index 871f9315c3..82a86446a0 100644 --- a/src/gui/kernel/qinputdevicemanager_p_p.h +++ b/src/gui/kernel/qinputdevicemanager_p_p.h @@ -69,7 +69,7 @@ public: int deviceCount(QInputDeviceManager::DeviceType type) const; void setDeviceCount(QInputDeviceManager::DeviceType type, int count); - std::array m_deviceCount; + std::array m_deviceCount = {}; Qt::KeyboardModifiers keyboardModifiers; }; -- cgit v1.2.3 From bfbf8ca4536fda39a8fb34dbf149794437f68dff Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 7 Jan 2020 09:58:14 +0100 Subject: Silence deprecation warning about QImage::alphaChannel() in qpixmap.h Amends aa542be4e005b1feedc2e17fd6ca2387bf2fea1b. Change-Id: Id1a256a101cc16fa36d1254d3523cf0732c24045 Reviewed-by: Allan Sandfeld Jensen --- src/gui/image/qpixmap.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gui') diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 8c1395857e..8a06ebe603 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -227,7 +227,10 @@ inline bool QPixmap::loadFromData(const QByteArray &buf, const char *format, #if QT_DEPRECATED_SINCE(5, 0) inline QPixmap QPixmap::alphaChannel() const { + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED return QPixmap::fromImage(toImage().alphaChannel()); + QT_WARNING_POP } inline void QPixmap::setAlphaChannel(const QPixmap &p) -- cgit v1.2.3 From 89c4bb5f2473b4616fdccbcc616eedfaa5d628cc Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 8 Jan 2020 13:43:54 +0100 Subject: Deprecate QJsonDocument methods for converting to/from JSON binary Also remove the example code for deprecated methods and use CBOR instead where it makes sense. Task-number: QTBUG-81068 Change-Id: Iffb7a4b3d7b16a1e485fc05b3ab2e2468e9e0718 Reviewed-by: Ulf Hermann --- src/gui/rhi/qshaderdescription.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index d0f73f6aa7..7e9b7d7b8e 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -342,8 +342,11 @@ bool QShaderDescription::isValid() const */ QByteArray QShaderDescription::toBinaryJson() const { -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED return d->makeDoc().toBinaryData(); +QT_WARNING_POP #else qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature"); return QByteArray(); @@ -382,8 +385,11 @@ QByteArray QShaderDescription::toJson() const QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) { QShaderDescription desc; -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data)); +QT_WARNING_POP #else Q_UNUSED(data); qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); -- cgit v1.2.3 From 2671fb27773fa318cde486d310dcf853a8290639 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 8 Jan 2020 13:23:59 +0100 Subject: rhi: Remove ugly fallthroughs The coding style does not actually require this. Change-Id: I2be7cd29c4dabfed2822cd7fb63e597c071e5e15 Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhid3d11.cpp | 26 -------------------------- src/gui/rhi/qrhigles2.cpp | 13 ------------- src/gui/rhi/qrhimetal.mm | 12 ------------ src/gui/rhi/qrhivulkan.cpp | 21 --------------------- 4 files changed, 72 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index c5923fe411..e58ce88095 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -630,9 +630,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); @@ -644,9 +642,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); @@ -1128,39 +1124,24 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return srgb ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; case QRhiTexture::ETC2_RGB8: - Q_FALLTHROUGH(); case QRhiTexture::ETC2_RGB8A1: - Q_FALLTHROUGH(); case QRhiTexture::ETC2_RGBA8: qWarning("QRhiD3D11 does not support ETC2 textures"); return DXGI_FORMAT_R8G8B8A8_UNORM; case QRhiTexture::ASTC_4x4: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_5x4: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_5x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_6x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_6x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x8: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x8: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x10: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_12x10: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_12x12: qWarning("QRhiD3D11 does not support ASTC textures"); return DXGI_FORMAT_R8G8B8A8_UNORM; @@ -1201,7 +1182,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format) { switch (format) { case QRhiTexture::Format::D16: - Q_FALLTHROUGH(); case QRhiTexture::Format::D32F: return true; @@ -1867,9 +1847,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD) } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); @@ -1885,9 +1863,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD) } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); @@ -3356,11 +3332,9 @@ static inline D3D11_BLEND toD3DBlendFactor(QRhiGraphicsPipeline::BlendFactor f) case QRhiGraphicsPipeline::OneMinusDstAlpha: return D3D11_BLEND_INV_DEST_ALPHA; case QRhiGraphicsPipeline::ConstantColor: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::ConstantAlpha: return D3D11_BLEND_BLEND_FACTOR; case QRhiGraphicsPipeline::OneMinusConstantColor: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusConstantAlpha: return D3D11_BLEND_INV_BLEND_FACTOR; case QRhiGraphicsPipeline::SrcAlphaSaturate: diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index e63ed11dd4..24ae0a3740 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -681,7 +681,6 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture switch (format) { case QRhiTexture::D16: - Q_FALLTHROUGH(); case QRhiTexture::D32F: return caps.depthTexture; @@ -695,7 +694,6 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture return caps.r16Format; case QRhiTexture::RGBA16F: - Q_FALLTHROUGH(); case QRhiTexture::RGBA32F: return caps.floatFormats; @@ -899,9 +897,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage)); break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex); @@ -917,9 +913,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf); @@ -1654,11 +1648,8 @@ static inline GLenum toGlBlendFactor(QRhiGraphicsPipeline::BlendFactor f) case QRhiGraphicsPipeline::SrcAlphaSaturate: return GL_SRC_ALPHA_SATURATE; case QRhiGraphicsPipeline::Src1Color: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusSrc1Color: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::Src1Alpha: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusSrc1Alpha: qWarning("Unsupported blend factor %d", f); return GL_ZERO; @@ -2573,9 +2564,7 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex); @@ -2591,9 +2580,7 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf); diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 222bf170dc..ef2de8c994 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -761,9 +761,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -786,9 +784,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); @@ -996,9 +992,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -1011,9 +1005,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); @@ -2928,9 +2920,7 @@ bool QMetalShaderResourceBindings::build() } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -2939,9 +2929,7 @@ bool QMetalShaderResourceBindings::build() } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index c5719b54aa..2c9249e911 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -864,7 +864,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format) { switch (format) { case QRhiTexture::Format::D16: - Q_FALLTHROUGH(); case QRhiTexture::Format::D32F: return true; @@ -2373,9 +2372,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex); @@ -2394,9 +2391,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf); @@ -3564,9 +3559,7 @@ static inline VkImageLayout toVkLayout(QRhiPassResourceTracker::TextureAccess ac case QRhiPassResourceTracker::TexDepthOutput: return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; case QRhiPassResourceTracker::TexStorageLoad: - Q_FALLTHROUGH(); case QRhiPassResourceTracker::TexStorageStore: - Q_FALLTHROUGH(); case QRhiPassResourceTracker::TexStorageLoadStore: return VK_IMAGE_LAYOUT_GENERAL; default: @@ -4045,9 +4038,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex); @@ -4072,9 +4063,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf); @@ -4863,16 +4852,12 @@ static inline VkDescriptorType toVkDescriptorType(const QRhiShaderResourceBindin return VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; @@ -6356,17 +6341,11 @@ static inline bool isSrgbFormat(VkFormat format) { switch (format) { case VK_FORMAT_R8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8B8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_B8G8R8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8B8A8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_B8G8R8A8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_A8B8G8R8_SRGB_PACK32: return true; default: -- cgit v1.2.3 From e4d0187edc8aa5c70d181728b18630c1749ca288 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 8 Jan 2020 11:15:42 +0100 Subject: rhi: metal: Fix incorrect native res. binding map check Checking for nullptr is insufficient: just because there is an empty map present, it does not mean it is valid. The two cases must be handled identically. This fixes a regression when using QShaders that do not have an associated native resource binding map. Amends 4639660dedceba7c16e1a8110bba16eff30be312 Change-Id: Icb239bf9a9261ed32f2cb7b22c60b608195618fc Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhimetal.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index ef2de8c994..53422470e8 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -664,15 +664,15 @@ static inline int mapBinding(int binding, BindingType type) { const QShader::NativeResourceBindingMap *map = nativeResourceBindingMaps[stageIndex]; - if (!map) + if (!map || map->isEmpty()) return binding; // old QShader versions do not have this map, assume 1:1 mapping then auto it = map->constFind(binding); if (it != map->cend()) return type == BindingType::Sampler ? it->second : it->first; // may be -1, if the resource is inactive - // Hitting this path is normal too, is not given that the resource (e.g. a - // uniform block) is really present in the shaders for all the stages + // Hitting this path is normal too. It is not given that the resource (for + // example, a uniform block) is present in the shaders for all the stages // specified by the visibility mask in the QRhiShaderResourceBinding. return -1; } -- cgit v1.2.3 From e8199a5c4d8c7218178db809bbfc0464f49714b1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 9 Jan 2020 15:28:54 +0100 Subject: rhi: Add R16F and R32F Can be relevant for Qt Quick 3D shadows, where the shadow map is R16F. Task-number: QTBUG-81268 Change-Id: Ic33e100929e133d1cbe0b062a15697c82536f62a Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhi.cpp | 6 ++++++ src/gui/rhi/qrhi_p.h | 2 ++ src/gui/rhi/qrhid3d11.cpp | 4 ++++ src/gui/rhi/qrhigles2.cpp | 24 ++++++++++++++++++++++++ src/gui/rhi/qrhimetal.mm | 4 ++++ src/gui/rhi/qrhivulkan.cpp | 4 ++++ 6 files changed, 44 insertions(+) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 00d4df53bd..d2c8ae104e 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -3939,6 +3939,12 @@ void QRhiImplementation::textureFormatInfo(QRhiTexture::Format format, const QSi case QRhiTexture::RGBA32F: bpc = 16; break; + case QRhiTexture::R16F: + bpc = 2; + break; + case QRhiTexture::R32F: + bpc = 4; + break; case QRhiTexture::D16: bpc = 2; diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index a6c65aac5e..3a64835c22 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -728,6 +728,8 @@ public: RGBA16F, RGBA32F, + R16F, + R32F, D16, D32F, diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index e58ce88095..445d162595 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1102,6 +1102,10 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return DXGI_FORMAT_R16G16B16A16_FLOAT; case QRhiTexture::RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case QRhiTexture::R16F: + return DXGI_FORMAT_R16_FLOAT; + case QRhiTexture::R32F: + return DXGI_FORMAT_R32_FLOAT; case QRhiTexture::D16: return DXGI_FORMAT_R16_TYPELESS; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 24ae0a3740..afa3a397e6 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -165,6 +165,14 @@ QT_BEGIN_NAMESPACE #define GL_RGBA16F 0x881A #endif +#ifndef GL_R16F +#define GL_R16F 0x822D +#endif + +#ifndef GL_R32F +#define GL_R32F 0x822E +#endif + #ifndef GL_HALF_FLOAT #define GL_HALF_FLOAT 0x140B #endif @@ -697,6 +705,10 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture case QRhiTexture::RGBA32F: return caps.floatFormats; + case QRhiTexture::R16F: + case QRhiTexture::R32F: + return caps.floatFormats; + default: break; } @@ -3384,6 +3396,18 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize) glformat = GL_RGBA; gltype = GL_FLOAT; break; + case QRhiTexture::R16F: + glintformat = GL_R16F; + glsizedintformat = glintformat; + glformat = GL_RED; + gltype = GL_HALF_FLOAT; + break; + case QRhiTexture::R32F: + glintformat = GL_R32F; + glsizedintformat = glintformat; + glformat = GL_RED; + gltype = GL_FLOAT; + break; case QRhiTexture::D16: glintformat = GL_DEPTH_COMPONENT16; glsizedintformat = glintformat; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 53422470e8..883d6923b9 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -2320,6 +2320,10 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR return MTLPixelFormatRGBA16Float; case QRhiTexture::RGBA32F: return MTLPixelFormatRGBA32Float; + case QRhiTexture::R16F: + return MTLPixelFormatR16Float; + case QRhiTexture::R32F: + return MTLPixelFormatR32Float; case QRhiTexture::D16: #ifdef Q_OS_MACOS diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 2c9249e911..c4f56f2dd2 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -767,6 +767,10 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture return VK_FORMAT_R16G16B16A16_SFLOAT; case QRhiTexture::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; + case QRhiTexture::R16F: + return VK_FORMAT_R16_SFLOAT; + case QRhiTexture::R32F: + return VK_FORMAT_R32_SFLOAT; case QRhiTexture::D16: return VK_FORMAT_D16_UNORM; -- cgit v1.2.3 From f1e5c5575cc362bc23da500d069dc98e082492e4 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 7 Jan 2020 11:29:04 +0100 Subject: Remove use of QImage::alphaChannel() A direct logical replacement. Not sure what is going on though or why an inversion is necessary, but logic is unchanged. Change-Id: Id9b5531895371f6467018fa82336aff6238ae126 Reviewed-by: Friedemann Kleint Reviewed-by: Eirik Aavitsland --- src/gui/painting/qtextureglyphcache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index f40ca9d8b4..91214f27ca 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -341,9 +341,10 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP } else if (m_format == QFontEngine::Format_Mono) { if (mask.depth() > 1) { // TODO optimize this - mask = mask.alphaChannel(); + mask.convertTo(QImage::Format_Alpha8); + mask.reinterpretAsFormat(QImage::Format_Grayscale8); mask.invertPixels(); - mask = mask.convertToFormat(QImage::Format_Mono, Qt::ThresholdDither); + mask.convertTo(QImage::Format_Mono, Qt::ThresholdDither); } int mw = qMin(mask.width(), c.w); -- cgit v1.2.3 From 69e7dfdb289b65ac27b581a164aefbbc28fc4fae Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 9 Jan 2020 10:50:35 +0100 Subject: Remove QShaderDescription::toBinaryJson(), deprecated fromBinaryJson() Binary Json is deprecated and we should not use it. We can already serialize shaders to CBOR. Push the deprecation warning mechanism to the only user of fromBinaryJson(). Change-Id: I1d56157ab92f74eaab49400be647317e7833e35e Reviewed-by: Sona Kurazyan Reviewed-by: Laszlo Agocs --- src/gui/rhi/qshader.cpp | 13 +++++++++++-- src/gui/rhi/qshaderdescription.cpp | 37 ++++++++----------------------------- src/gui/rhi/qshaderdescription_p.h | 4 +++- 3 files changed, 22 insertions(+), 32 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 0b99281f08..9203d63cd2 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -439,10 +439,19 @@ QShader QShader::fromSerialized(const QByteArray &data) d->stage = Stage(intVal); QByteArray descBin; ds >> descBin; - if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) + if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) { d->desc = QShaderDescription::fromCbor(descBin); - else + } else { +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED d->desc = QShaderDescription::fromBinaryJson(descBin); + QT_WARNING_POP +#else + qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); + d->desc = QShaderDescription(); +#endif + } int count; ds >> count; for (int i = 0; i < count; ++i) { diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index 7e9b7d7b8e..76c5d0ebef 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -102,8 +102,8 @@ QT_BEGIN_NAMESPACE float \c opacity at offset 64. All this is described by a QShaderDescription object. QShaderDescription - can also be serialized to JSON and binary JSON, and can be deserialized - from binary JSON. In practice this is rarely needed since QShader + can also be serialized to JSON and CBOR, and can be deserialized + from CBOR. In practice this is rarely needed since QShader takes care of the associated QShaderDescription automatically, but if the QShaderDescription of the above shader would be written out as JSON, it would look like the following: @@ -335,29 +335,11 @@ bool QShaderDescription::isValid() const || !d->combinedImageSamplers.isEmpty() || !d->storageImages.isEmpty(); } -/*! - \return a serialized binary version of the data. - - \sa toJson(), toCbor() - */ -QByteArray QShaderDescription::toBinaryJson() const -{ -#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - return d->makeDoc().toBinaryData(); -QT_WARNING_POP -#else - qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature"); - return QByteArray(); -#endif -} - /*! \return a serialized binary version of the data in CBOR (Concise Binary Object Representation) format. - \sa QCborValue, toBinaryJson(), toJson() + \sa QCborValue, toJson() */ QByteArray QShaderDescription::toCbor() const { @@ -369,14 +351,17 @@ QByteArray QShaderDescription::toCbor() const \note There is no deserialization method provided for JSON text. - \sa toBinaryJson(), toCbor() + \sa toCbor() */ QByteArray QShaderDescription::toJson() const { return d->makeDoc().toJson(); } +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + Deserializes the given binary JSON \a data and returns a new QShaderDescription. @@ -385,22 +370,16 @@ QByteArray QShaderDescription::toJson() const QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) { QShaderDescription desc; -#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data)); QT_WARNING_POP -#else - Q_UNUSED(data); - qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); -#endif return desc; } +#endif /*! Deserializes the given CBOR \a data and returns a new QShaderDescription. - - \sa fromBinaryJson() */ QShaderDescription QShaderDescription::fromCbor(const QByteArray &data) { diff --git a/src/gui/rhi/qshaderdescription_p.h b/src/gui/rhi/qshaderdescription_p.h index e02a53dcb5..872ee8b138 100644 --- a/src/gui/rhi/qshaderdescription_p.h +++ b/src/gui/rhi/qshaderdescription_p.h @@ -68,11 +68,13 @@ public: bool isValid() const; - QByteArray toBinaryJson() const; QByteArray toCbor() const; QByteArray toJson() const; +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use CBOR format instead") static QShaderDescription fromBinaryJson(const QByteArray &data); +#endif static QShaderDescription fromCbor(const QByteArray &data); enum VariableType { -- cgit v1.2.3 From c584380c6901b1bcd9f8100fa1087b09d3cb023d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 10 Jan 2020 13:20:42 +0100 Subject: Windows QPA: Update documentation on command line options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sort alphabetically and add recent relevant options with version information. Change-Id: I10c8cc82ce357775ed68cb811a0c906cd38633a5 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bdcea275c3..2b3299f745 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -605,8 +605,13 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME The following parameters are available for \c {-platform windows}: \list + \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as + Qt::GroupSwitchModifier (since Qt 5.12). \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and \c none disables them. + + \li \c {dpiawareness=[0|1|2} Sets the DPI awareness of the process + (see \l{High DPI Displays}, since Qt 5.4). \li \c {fontengine=freetype}, uses the FreeType font engine. \li \c {menus=[native|none]}, controls the use of native menus. @@ -616,10 +621,23 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME provide hover signals. They are mainly intended for Qt Quick. By default, they will be used if the application is not an instance of QApplication or for Qt Quick Controls 2 - applications. + applications (since Qt 5.10). - \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as - Qt::GroupSwitchModifier. + \li \c {nocolorfonts} Turn off DirectWrite Color fonts + (since Qt 5.8). + + \li \c {nodirectwrite} Turn off DirectWrite fonts (since Qt 5.8). + + \li \c {nomousefromtouch} Ignores mouse events synthesized + from touch events by the operating system. + + \li \c {nowmpointer} Switches from Pointer Input Messages handling + to legacy mouse handling (since Qt 5.12). + \li \c {reverse} Activates Right-to-left mode (experimental). + Windows title bars will be shown accordingly in Right-to-left locales + (since Qt 5.13). + \li \c {tabletabsoluterange=} Sets a value for mouse mode detection + of WinTab tablets (Legacy, since Qt 5.3). \endlist The following parameter is available for \c {-platform cocoa} (on macOS): -- cgit v1.2.3 From 76fbe75abee7d77911467d56630176f777e8ed78 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Tue, 7 Jan 2020 09:13:21 +0100 Subject: Remove empty block at beginning of imported markdown An empty QTextDocument already contains a block; so when the formatting is fully determined, if the document is still empty, then instead of inserting a new block, we can set formatting on the cursor, which affects the pre-existing block, before inserting text. This avoids leaving a blank line (the default block) above the inserted content. Fixes: QTBUG-81060 Change-Id: I14e45e300a602493aa59680417d74d4c2b25862d Reviewed-by: Shawn Rutledge --- src/gui/text/qtextmarkdownimporter.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 78d18a714b..88965046ce 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -207,7 +207,12 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) charFmt.setFontWeight(QFont::Bold); blockFmt.setHeadingLevel(int(detail->level)); m_needsInsertBlock = false; - m_cursor->insertBlock(blockFmt, charFmt); + if (m_doc->isEmpty()) { + m_cursor->setBlockFormat(blockFmt); + m_cursor->setCharFormat(charFmt); + } else { + m_cursor->insertBlock(blockFmt, charFmt); + } qCDebug(lcMD, "H%d", detail->level); } break; case MD_BLOCK_LI: { @@ -592,7 +597,12 @@ void QTextMarkdownImporter::insertBlock() blockFormat.setMarker(m_markerType); if (!m_listStack.isEmpty()) blockFormat.setIndent(m_listStack.count()); - m_cursor->insertBlock(blockFormat, charFormat); + if (m_doc->isEmpty()) { + m_cursor->setBlockFormat(blockFormat); + m_cursor->setCharFormat(charFormat); + } else { + m_cursor->insertBlock(blockFormat, charFormat); + } if (m_needsInsertList) { m_listStack.push(m_cursor->createList(m_listFormat)); } else if (!m_listStack.isEmpty() && m_listItem) { -- cgit v1.2.3 From 41b44c6f21442892e2c0749940f716dc91c74b1f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 1 Jan 2020 06:24:26 +0100 Subject: doc: explain QWheelEvent::angleDelta() more thoroughly It has been a QPoint for a long time now, to support both the usual vertical mouse wheel and also the wheel tilt for horizontal scrolling, or the actual horizontal wheel if the mouse has one, or the simulation of a horizontal wheel via touchpad gestures; but the docs continued to read as if it was just one value. Task-number: QTBUG-71575 Change-Id: I3efa686ace4f09c7f237f72bf0500fbfbd3213cb Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qevent.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f555f4dc05..0706ae3e90 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -667,9 +667,9 @@ QHoverEvent::~QHoverEvent() if that widget does not handle the event they are sent to the focus widget. Wheel events are generated for both mouse wheels and trackpad scroll gestures. There are two ways to read the - wheel event delta: angleDelta() returns the delta in wheel - degrees. This value is always provided. pixelDelta() returns - the delta in screen pixels and is available on platforms that + wheel event delta: angleDelta() returns the deltas in wheel + degrees. These values are always provided. pixelDelta() returns + the deltas in screen pixels, and is available on platforms that have high-resolution trackpads, such as \macos. If that is the case, source() will return Qt::MouseEventSynthesizedBySystem. @@ -852,7 +852,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, by \a globalPos. \a pixelDelta contains the scrolling distance in pixels on screen, while - \a angleDelta contains the wheel rotation distance. \a pixelDelta is + \a angleDelta contains the wheel rotation angle. \a pixelDelta is optional and can be null. The mouse and keyboard states at the time of the event are specified by @@ -914,10 +914,16 @@ QWheelEvent::~QWheelEvent() /*! \fn QPoint QWheelEvent::angleDelta() const - Returns the distance that the wheel is rotated, in eighths of a - degree. A positive value indicates that the wheel was rotated - forwards away from the user; a negative value indicates that the - wheel was rotated backwards toward the user. + Returns the relative amount that the wheel was rotated, in eighths of a + degree. A positive value indicates that the wheel was rotated forwards away + from the user; a negative value indicates that the wheel was rotated + backwards toward the user. \c angleDelta().y() provides the angle through + which the common vertical mouse wheel was rotated since the previous event. + \c angleDelta().x() provides the angle through which the horizontal mouse + wheel was rotated, if the mouse has a horizontal wheel; otherwise it stays + at zero. Some mice allow the user to tilt the wheel to perform horizontal + scrolling, and some touchpads support a horizontal scrolling gesture; that + will also appear in \c angleDelta().x(). Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees. @@ -926,7 +932,9 @@ QWheelEvent::~QWheelEvent() that are less than 120 units (less than 15 degrees). To support this possibility, you can either cumulatively add the delta values from events until the value of 120 is reached, then scroll the widget, or you can - partially scroll the widget in response to each wheel event. + partially scroll the widget in response to each wheel event. But to + provide a more native feel, you should prefer \l pixelDelta() on platforms + where it's available. Example: @@ -937,6 +945,8 @@ QWheelEvent::~QWheelEvent() \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin), \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). \endlist + + \see pixelDelta() */ /*! -- cgit v1.2.3 From 62e98af40f97b865aeed897e90231e76b329d614 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 9 Jan 2020 15:08:11 +0100 Subject: rhi: gl: Do not issue glMemoryBarrier when compute is not supported Avoid crashing in a < GLES 3.1 and < GL 4.3 contexts. Change-Id: I0f713a527890ec209c967ebb6c5bb3baa77d9a31 Reviewed-by: Eirik Aavitsland --- src/gui/rhi/qrhigles2.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index afa3a397e6..81a1daa16b 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2287,12 +2287,13 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) barriers |= GL_ALL_BARRIER_BITS; } } - if (barriers) + if (barriers && caps.compute) f->glMemoryBarrier(barriers); } break; case QGles2CommandBuffer::Command::Barrier: - f->glMemoryBarrier(cmd.args.barrier.barriers); + if (caps.compute) + f->glMemoryBarrier(cmd.args.barrier.barriers); break; default: break; -- cgit v1.2.3 From 9a0ab41f28042c7f27208337e419435d16f00006 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 8 Jan 2020 12:55:57 +0100 Subject: rhi: gl: vulkan: Generate barriers between dispatches in a compute pass The new float16texture_with_compute manual test demonstrates a case that was not handled correctly before: multiple dispatch() calls in a row storing to and then loading from the same subresource(s). Without the appropriate barriers subtle data corruption issues appear. For Vulkan this also adds better batching for image/buffer barriers when using deferred recording. Also, for OpenGL this fixes the case of updating a buffer or rendering into a texture and then using it for load/store in a compute pass (previously this also lacked an appropriate glMemoryBarrier). Task-number: QTBUG-81217 Change-Id: I7970c445564473f9452662f4b1a20618cb8627a3 Reviewed-by: Paul Olav Tvete Reviewed-by: Johan Helsing --- src/gui/rhi/qrhigles2.cpp | 124 +++++++++++++++++++++++++++++++--- src/gui/rhi/qrhigles2_p_p.h | 11 +++ src/gui/rhi/qrhivulkan.cpp | 157 +++++++++++++++++++++++++++++++++++++++++-- src/gui/rhi/qrhivulkan_p_p.h | 17 ++++- 4 files changed, 291 insertions(+), 18 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 81a1daa16b..ec5e531e14 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -269,6 +269,14 @@ QT_BEGIN_NAMESPACE #define GL_ALL_BARRIER_BITS 0xFFFFFFFF #endif +#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#endif + +#ifndef GL_SHADER_STORAGE_BARRIER_BIT +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#endif + #ifndef GL_VERTEX_PROGRAM_POINT_SIZE #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 #endif @@ -1307,6 +1315,21 @@ QRhi::FrameOpResult QRhiGles2::finish() return QRhi::FrameOpSuccess; } +static bool bufferAccessIsWrite(QGles2Buffer::Access access) +{ + return access == QGles2Buffer::AccessStorageWrite + || access == QGles2Buffer::AccessStorageReadWrite + || access == QGles2Buffer::AccessUpdate; +} + +static bool textureAccessIsWrite(QGles2Texture::Access access) +{ + return access == QGles2Texture::AccessStorageWrite + || access == QGles2Texture::AccessStorageReadWrite + || access == QGles2Texture::AccessUpdate + || access == QGles2Texture::AccessFramebuffer; +} + void QRhiGles2::trackedBufferBarrier(QGles2CommandBuffer *cbD, QGles2Buffer *bufD, QGles2Buffer::Access access) { Q_ASSERT(cbD->recordingPass == QGles2CommandBuffer::NoPass); // this is for resource updates only @@ -1314,7 +1337,7 @@ void QRhiGles2::trackedBufferBarrier(QGles2CommandBuffer *cbD, QGles2Buffer *buf if (access == prevAccess) return; - if (prevAccess == QGles2Buffer::AccessStorageWrite || prevAccess == QGles2Buffer::AccessStorageReadWrite) { + if (bufferAccessIsWrite(prevAccess)) { // Generating the minimal barrier set is way too complicated to do // correctly (prevAccess is overwritten so we won't have proper // tracking across multiple passes) so setting all barrier bits will do @@ -1335,7 +1358,7 @@ void QRhiGles2::trackedImageBarrier(QGles2CommandBuffer *cbD, QGles2Texture *tex if (access == prevAccess) return; - if (prevAccess == QGles2Texture::AccessStorageWrite || prevAccess == QGles2Texture::AccessStorageReadWrite) { + if (textureAccessIsWrite(prevAccess)) { QGles2CommandBuffer::Command cmd; cmd.cmd = QGles2CommandBuffer::Command::Barrier; cmd.args.barrier.barriers = GL_ALL_BARRIER_BITS; @@ -2273,19 +2296,13 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) // subsequent pass. for (auto it = tracker.cbeginBuffers(), itEnd = tracker.cendBuffers(); it != itEnd; ++it) { QGles2Buffer::Access accessBeforePass = QGles2Buffer::Access(it->stateAtPassBegin.access); - if (accessBeforePass == QGles2Buffer::AccessStorageWrite - || accessBeforePass == QGles2Buffer::AccessStorageReadWrite) - { + if (bufferAccessIsWrite(accessBeforePass)) barriers |= GL_ALL_BARRIER_BITS; - } } for (auto it = tracker.cbeginTextures(), itEnd = tracker.cendTextures(); it != itEnd; ++it) { QGles2Texture::Access accessBeforePass = QGles2Texture::Access(it->stateAtPassBegin.access); - if (accessBeforePass == QGles2Texture::AccessStorageWrite - || accessBeforePass == QGles2Texture::AccessStorageReadWrite) - { + if (textureAccessIsWrite(accessBeforePass)) barriers |= GL_ALL_BARRIER_BITS; - } } if (barriers && caps.compute) f->glMemoryBarrier(barriers); @@ -2792,6 +2809,8 @@ void QRhiGles2::beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch cbD->recordingPass = QGles2CommandBuffer::ComputePass; cbD->resetCachedState(); + + cbD->computePassState.reset(); } void QRhiGles2::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) @@ -2824,11 +2843,96 @@ void QRhiGles2::setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *p } } +template +inline void qrhigl_accumulateComputeResource(T *writtenResources, QRhiResource *resource, + QRhiShaderResourceBinding::Type bindingType, + int loadTypeVal, int storeTypeVal, int loadStoreTypeVal) +{ + int access = 0; + if (bindingType == loadTypeVal) { + access = QGles2CommandBuffer::ComputePassState::Read; + } else { + access = QGles2CommandBuffer::ComputePassState::Write; + if (bindingType == loadStoreTypeVal) + access |= QGles2CommandBuffer::ComputePassState::Read; + } + auto it = writtenResources->find(resource); + if (it != writtenResources->end()) + it->first |= access; + else if (bindingType == storeTypeVal || bindingType == loadStoreTypeVal) + writtenResources->insert(resource, { access, true }); +} + void QRhiGles2::dispatch(QRhiCommandBuffer *cb, int x, int y, int z) { QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QGles2CommandBuffer::ComputePass); + if (cbD->currentComputeSrb) { + GLbitfield barriers = 0; + + // The key in the writtenResources map indicates that the resource was + // written in a previous dispatch, whereas the value accumulates the + // access mask in the current one. + for (auto &accessAndIsNewFlag : cbD->computePassState.writtenResources) + accessAndIsNewFlag = { 0, false }; + + QGles2ShaderResourceBindings *srbD = QRHI_RES(QGles2ShaderResourceBindings, cbD->currentComputeSrb); + const int bindingCount = srbD->m_bindings.count(); + for (int i = 0; i < bindingCount; ++i) { + const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); + switch (b->type) { + case QRhiShaderResourceBinding::ImageLoad: + case QRhiShaderResourceBinding::ImageStore: + case QRhiShaderResourceBinding::ImageLoadStore: + qrhigl_accumulateComputeResource(&cbD->computePassState.writtenResources, + b->u.simage.tex, + b->type, + QRhiShaderResourceBinding::ImageLoad, + QRhiShaderResourceBinding::ImageStore, + QRhiShaderResourceBinding::ImageLoadStore); + break; + case QRhiShaderResourceBinding::BufferLoad: + case QRhiShaderResourceBinding::BufferStore: + case QRhiShaderResourceBinding::BufferLoadStore: + qrhigl_accumulateComputeResource(&cbD->computePassState.writtenResources, + b->u.sbuf.buf, + b->type, + QRhiShaderResourceBinding::BufferLoad, + QRhiShaderResourceBinding::BufferStore, + QRhiShaderResourceBinding::BufferLoadStore); + break; + default: + break; + } + } + + for (auto it = cbD->computePassState.writtenResources.begin(); it != cbD->computePassState.writtenResources.end(); ) { + const int accessInThisDispatch = it->first; + const bool isNewInThisDispatch = it->second; + if (accessInThisDispatch && !isNewInThisDispatch) { + if (it.key()->resourceType() == QRhiResource::Texture) + barriers |= GL_SHADER_IMAGE_ACCESS_BARRIER_BIT; + else + barriers |= GL_SHADER_STORAGE_BARRIER_BIT; + } + // Anything that was previously written, but is only read now, can be + // removed from the written list (because that previous write got a + // corresponding barrier now). + if (accessInThisDispatch == QGles2CommandBuffer::ComputePassState::Read) + it = cbD->computePassState.writtenResources.erase(it); + else + ++it; + } + + if (barriers) { + QGles2CommandBuffer::Command cmd; + cmd.cmd = QGles2CommandBuffer::Command::Barrier; + cmd.args.barrier.barriers = barriers; + cbD->commands.append(cmd); + } + } + QGles2CommandBuffer::Command cmd; cmd.cmd = QGles2CommandBuffer::Command::Dispatch; cmd.args.dispatch.x = GLuint(x); diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index a9b3022612..679f806004 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -521,6 +521,17 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer QRhiShaderResourceBindings *currentComputeSrb; uint currentSrbGeneration; + struct ComputePassState { + enum Access { + Read = 0x01, + Write = 0x02 + }; + QHash > writtenResources; + void reset() { + writtenResources.clear(); + } + } computePassState; + QVector dataRetainPool; QVector imageRetainPool; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index c4f56f2dd2..f4c72d2cca 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -2219,6 +2219,8 @@ void QRhiVulkan::beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch cbD->recordingPass = QVkCommandBuffer::ComputePass; + cbD->computePassState.reset(); + if (cbD->useSecondaryCb) cbD->secondaryCbs.append(startSecondaryCommandBuffer()); } @@ -2267,15 +2269,152 @@ void QRhiVulkan::setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline * psD->lastActiveFrameSlot = currentFrameSlot; } +template +inline void qrhivk_accumulateComputeResource(T *writtenResources, QRhiResource *resource, + QRhiShaderResourceBinding::Type bindingType, + int loadTypeVal, int storeTypeVal, int loadStoreTypeVal) +{ + VkAccessFlags access = 0; + if (bindingType == loadTypeVal) { + access = VK_ACCESS_SHADER_READ_BIT; + } else { + access = VK_ACCESS_SHADER_WRITE_BIT; + if (bindingType == loadStoreTypeVal) + access |= VK_ACCESS_SHADER_READ_BIT; + } + auto it = writtenResources->find(resource); + if (it != writtenResources->end()) + it->first |= access; + else if (bindingType == storeTypeVal || bindingType == loadStoreTypeVal) + writtenResources->insert(resource, { access, true }); +} + void QRhiVulkan::dispatch(QRhiCommandBuffer *cb, int x, int y, int z) { QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QVkCommandBuffer::ComputePass); + // When there are multiple dispatches, read-after-write and + // write-after-write need a barrier. + QVarLengthArray imageBarriers; + QVarLengthArray bufferBarriers; + if (cbD->currentComputeSrb) { + // The key in the writtenResources map indicates that the resource was + // written in a previous dispatch, whereas the value accumulates the + // access mask in the current one. + for (auto &accessAndIsNewFlag : cbD->computePassState.writtenResources) + accessAndIsNewFlag = { 0, false }; + + QVkShaderResourceBindings *srbD = QRHI_RES(QVkShaderResourceBindings, cbD->currentComputeSrb); + const int bindingCount = srbD->m_bindings.count(); + for (int i = 0; i < bindingCount; ++i) { + const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); + switch (b->type) { + case QRhiShaderResourceBinding::ImageLoad: + case QRhiShaderResourceBinding::ImageStore: + case QRhiShaderResourceBinding::ImageLoadStore: + qrhivk_accumulateComputeResource(&cbD->computePassState.writtenResources, + b->u.simage.tex, + b->type, + QRhiShaderResourceBinding::ImageLoad, + QRhiShaderResourceBinding::ImageStore, + QRhiShaderResourceBinding::ImageLoadStore); + break; + case QRhiShaderResourceBinding::BufferLoad: + case QRhiShaderResourceBinding::BufferStore: + case QRhiShaderResourceBinding::BufferLoadStore: + qrhivk_accumulateComputeResource(&cbD->computePassState.writtenResources, + b->u.sbuf.buf, + b->type, + QRhiShaderResourceBinding::BufferLoad, + QRhiShaderResourceBinding::BufferStore, + QRhiShaderResourceBinding::BufferLoadStore); + break; + default: + break; + } + } + + for (auto it = cbD->computePassState.writtenResources.begin(); it != cbD->computePassState.writtenResources.end(); ) { + const int accessInThisDispatch = it->first; + const bool isNewInThisDispatch = it->second; + if (accessInThisDispatch && !isNewInThisDispatch) { + if (it.key()->resourceType() == QRhiResource::Texture) { + QVkTexture *texD = QRHI_RES(QVkTexture, it.key()); + VkImageMemoryBarrier barrier; + memset(&barrier, 0, sizeof(barrier)); + barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + // won't care about subresources, pretend the whole resource was written + barrier.subresourceRange.baseMipLevel = 0; + barrier.subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS; + barrier.subresourceRange.baseArrayLayer = 0; + barrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS; + barrier.oldLayout = texD->usageState.layout; + barrier.newLayout = texD->usageState.layout; + barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + barrier.dstAccessMask = accessInThisDispatch; + barrier.image = texD->image; + imageBarriers.append(barrier); + } else { + QVkBuffer *bufD = QRHI_RES(QVkBuffer, it.key()); + VkBufferMemoryBarrier barrier; + memset(&barrier, 0, sizeof(barrier)); + barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; + barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + barrier.dstAccessMask = accessInThisDispatch; + barrier.buffer = bufD->buffers[bufD->m_type == QRhiBuffer::Dynamic ? currentFrameSlot : 0]; + barrier.size = VK_WHOLE_SIZE; + bufferBarriers.append(barrier); + } + } + // Anything that was previously written, but is only read now, can be + // removed from the written list (because that previous write got a + // corresponding barrier now). + if (accessInThisDispatch == VK_ACCESS_SHADER_READ_BIT) + it = cbD->computePassState.writtenResources.erase(it); + else + ++it; + } + } + if (cbD->useSecondaryCb) { - df->vkCmdDispatch(cbD->secondaryCbs.last(), uint32_t(x), uint32_t(y), uint32_t(z)); + VkCommandBuffer secondaryCb = cbD->secondaryCbs.last(); + if (!imageBarriers.isEmpty()) { + df->vkCmdPipelineBarrier(secondaryCb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, 0, nullptr, + 0, nullptr, + imageBarriers.count(), imageBarriers.constData()); + } + if (!bufferBarriers.isEmpty()) { + df->vkCmdPipelineBarrier(secondaryCb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, 0, nullptr, + bufferBarriers.count(), bufferBarriers.constData(), + 0, nullptr); + } + df->vkCmdDispatch(secondaryCb, uint32_t(x), uint32_t(y), uint32_t(z)); } else { QVkCommandBuffer::Command cmd; + if (!imageBarriers.isEmpty()) { + cmd.cmd = QVkCommandBuffer::Command::ImageBarrier; + cmd.args.imageBarrier.srcStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + cmd.args.imageBarrier.dstStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + cmd.args.imageBarrier.count = imageBarriers.count(); + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cbD->pools.imageBarrier.append(imageBarriers.constData(), imageBarriers.count()); + cbD->commands.append(cmd); + } + if (!bufferBarriers.isEmpty()) { + cmd.cmd = QVkCommandBuffer::Command::BufferBarrier; + cmd.args.bufferBarrier.srcStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + cmd.args.bufferBarrier.dstStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + cmd.args.bufferBarrier.count = bufferBarriers.count(); + cmd.args.bufferBarrier.index = cbD->pools.bufferBarrier.count(); + cbD->pools.bufferBarrier.append(bufferBarriers.constData(), bufferBarriers.count()); + cbD->commands.append(cmd); + } cmd.cmd = QVkCommandBuffer::Command::Dispatch; cmd.args.dispatch.x = x; cmd.args.dispatch.y = y; @@ -2465,7 +2604,9 @@ void QRhiVulkan::trackedBufferBarrier(QVkCommandBuffer *cbD, QVkBuffer *bufD, in cmd.cmd = QVkCommandBuffer::Command::BufferBarrier; cmd.args.bufferBarrier.srcStageMask = s.stage; cmd.args.bufferBarrier.dstStageMask = stage; - cmd.args.bufferBarrier.desc = bufMemBarrier; + cmd.args.bufferBarrier.count = 1; + cmd.args.bufferBarrier.index = cbD->pools.bufferBarrier.count(); + cbD->pools.bufferBarrier.append(bufMemBarrier); cbD->commands.append(cmd); s.access = access; @@ -2507,7 +2648,9 @@ void QRhiVulkan::trackedImageBarrier(QVkCommandBuffer *cbD, QVkTexture *texD, cmd.cmd = QVkCommandBuffer::Command::ImageBarrier; cmd.args.imageBarrier.srcStageMask = srcStage; cmd.args.imageBarrier.dstStageMask = stage; - cmd.args.imageBarrier.desc = barrier; + cmd.args.imageBarrier.count = 1; + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cbD->pools.imageBarrier.append(barrier); cbD->commands.append(cmd); s.layout = layout; @@ -2541,7 +2684,9 @@ void QRhiVulkan::subresourceBarrier(QVkCommandBuffer *cbD, VkImage image, cmd.cmd = QVkCommandBuffer::Command::ImageBarrier; cmd.args.imageBarrier.srcStageMask = srcStage; cmd.args.imageBarrier.dstStageMask = dstStage; - cmd.args.imageBarrier.desc = barrier; + cmd.args.imageBarrier.count = 1; + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cbD->pools.imageBarrier.append(barrier); cbD->commands.append(cmd); } @@ -3409,12 +3554,12 @@ void QRhiVulkan::recordPrimaryCommandBuffer(QVkCommandBuffer *cbD) case QVkCommandBuffer::Command::ImageBarrier: df->vkCmdPipelineBarrier(cbD->cb, cmd.args.imageBarrier.srcStageMask, cmd.args.imageBarrier.dstStageMask, 0, 0, nullptr, 0, nullptr, - 1, &cmd.args.imageBarrier.desc); + cmd.args.imageBarrier.count, cbD->pools.imageBarrier.constData() + cmd.args.imageBarrier.index); break; case QVkCommandBuffer::Command::BufferBarrier: df->vkCmdPipelineBarrier(cbD->cb, cmd.args.bufferBarrier.srcStageMask, cmd.args.bufferBarrier.dstStageMask, 0, 0, nullptr, - 1, &cmd.args.bufferBarrier.desc, + cmd.args.bufferBarrier.count, cbD->pools.bufferBarrier.constData() + cmd.args.bufferBarrier.index, 0, nullptr); break; case QVkCommandBuffer::Command::BlitImage: diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index 9f18d0bf5e..b0e90dae56 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -370,6 +370,13 @@ struct QVkCommandBuffer : public QRhiCommandBuffer QVarLengthArray secondaryCbs; bool inExternal; + struct { + QHash > writtenResources; + void reset() { + writtenResources.clear(); + } + } computePassState; + struct Command { enum Cmd { CopyBuffer, @@ -429,12 +436,14 @@ struct QVkCommandBuffer : public QRhiCommandBuffer struct { VkPipelineStageFlags srcStageMask; VkPipelineStageFlags dstStageMask; - VkImageMemoryBarrier desc; + int count; + int index; } imageBarrier; struct { VkPipelineStageFlags srcStageMask; VkPipelineStageFlags dstStageMask; - VkBufferMemoryBarrier desc; + int count; + int index; } bufferBarrier; struct { VkImage src; @@ -537,6 +546,8 @@ struct QVkCommandBuffer : public QRhiCommandBuffer pools.vertexBuffer.clear(); pools.vertexBufferOffset.clear(); pools.debugMarkerData.clear(); + pools.imageBarrier.clear(); + pools.bufferBarrier.clear(); } struct { @@ -546,6 +557,8 @@ struct QVkCommandBuffer : public QRhiCommandBuffer QVarLengthArray vertexBuffer; QVarLengthArray vertexBufferOffset; QVarLengthArray debugMarkerData; + QVarLengthArray imageBarrier; + QVarLengthArray bufferBarrier; } pools; friend class QRhiVulkan; -- cgit v1.2.3 From 7e2cef0f15b133c07bd11aa5e5065b0b9959fb0d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 12 Jan 2020 17:33:31 +0100 Subject: Move away from CBOR in QShaderDescription serialization ...but keep support for deserializing for all older versions in order to play nice with existing .qsb files. The usage of binary JSON and then CBOR is a historical artifact: relying on the QJsonDocument (which we generate for purposes unrelated to binary serialization) was a convenient shortcut. However, writing to and reading from a QDataStream instead (which QShader already does) is trivial. In order not to be limited by potential CBOR requirements in the future, take it all into our own hands. Extend the qshader autotest accordingly. Task-number: QTBUG-81298 Change-Id: If0047b659bd6601ca47b5bbbce1b719630cde01e Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qshader.cpp | 13 +- src/gui/rhi/qshader_p_p.h | 3 +- src/gui/rhi/qshaderdescription.cpp | 235 +++++++++++++++++++++++++++++++++++ src/gui/rhi/qshaderdescription_p.h | 3 + src/gui/rhi/qshaderdescription_p_p.h | 2 + 5 files changed, 251 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 9203d63cd2..69f4a68215 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -367,7 +367,7 @@ QByteArray QShader::serialized() const ds << QShaderPrivate::QSB_VERSION; ds << int(d->stage); - ds << d->desc.toCbor(); + d->desc.serialize(&ds); ds << d->shaders.count(); for (auto it = d->shaders.cbegin(), itEnd = d->shaders.cend(); it != itEnd; ++it) { const QShaderKey &k(it.key()); @@ -428,6 +428,7 @@ QShader QShader::fromSerialized(const QByteArray &data) ds >> intVal; d->qsbVersion = intVal; if (d->qsbVersion != QShaderPrivate::QSB_VERSION + && d->qsbVersion != QShaderPrivate::QSB_VERSION_WITH_CBOR && d->qsbVersion != QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON && d->qsbVersion != QShaderPrivate::QSB_VERSION_WITHOUT_BINDINGS) { @@ -437,14 +438,18 @@ QShader QShader::fromSerialized(const QByteArray &data) ds >> intVal; d->stage = Stage(intVal); - QByteArray descBin; - ds >> descBin; - if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) { + if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_CBOR) { + d->desc = QShaderDescription::deserialize(&ds); + } else if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) { + QByteArray descBin; + ds >> descBin; d->desc = QShaderDescription::fromCbor(descBin); } else { #if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED + QByteArray descBin; + ds >> descBin; d->desc = QShaderDescription::fromBinaryJson(descBin); QT_WARNING_POP #else diff --git a/src/gui/rhi/qshader_p_p.h b/src/gui/rhi/qshader_p_p.h index 8c89f2b45f..66ef18f391 100644 --- a/src/gui/rhi/qshader_p_p.h +++ b/src/gui/rhi/qshader_p_p.h @@ -57,7 +57,8 @@ QT_BEGIN_NAMESPACE struct Q_GUI_EXPORT QShaderPrivate { - static const int QSB_VERSION = 3; + static const int QSB_VERSION = 4; + static const int QSB_VERSION_WITH_CBOR = 3; static const int QSB_VERSION_WITH_BINARY_JSON = 2; static const int QSB_VERSION_WITHOUT_BINDINGS = 1; diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index 76c5d0ebef..96c8d082fc 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -36,6 +36,7 @@ #include "qshaderdescription_p_p.h" #include +#include #include #include #include @@ -358,6 +359,11 @@ QByteArray QShaderDescription::toJson() const return d->makeDoc().toJson(); } +void QShaderDescription::serialize(QDataStream *stream) const +{ + d->writeToStream(stream); +} + #if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! \deprecated @@ -396,6 +402,13 @@ QShaderDescription QShaderDescription::fromCbor(const QByteArray &data) return desc; } +QShaderDescription QShaderDescription::deserialize(QDataStream *stream) +{ + QShaderDescription desc; + QShaderDescriptionPrivate::get(&desc)->loadFromStream(stream); + return desc; +} + /*! \return the list of input variables. This includes vertex inputs (sometimes called attributes) for the vertex stage, and inputs for other stages @@ -867,6 +880,15 @@ static void addDeco(QJsonObject *obj, const QShaderDescription::InOutVariable &v (*obj)[imageFlagsKey] = int(v.imageFlags); } +static void serializeDecorations(QDataStream *stream, const QShaderDescription::InOutVariable &v) +{ + (*stream) << v.location; + (*stream) << v.binding; + (*stream) << v.descriptorSet; + (*stream) << int(v.imageFormat); + (*stream) << int(v.imageFlags); +} + static QJsonObject inOutObject(const QShaderDescription::InOutVariable &v) { QJsonObject obj; @@ -876,6 +898,13 @@ static QJsonObject inOutObject(const QShaderDescription::InOutVariable &v) return obj; } +static void serializeInOutVar(QDataStream *stream, const QShaderDescription::InOutVariable &v) +{ + (*stream) << v.name; + (*stream) << int(v.type); + serializeDecorations(stream, v); +} + static QJsonObject blockMemberObject(const QShaderDescription::BlockVariable &v) { QJsonObject obj; @@ -904,6 +933,23 @@ static QJsonObject blockMemberObject(const QShaderDescription::BlockVariable &v) return obj; } +static void serializeBlockMemberVar(QDataStream *stream, const QShaderDescription::BlockVariable &v) +{ + (*stream) << v.name; + (*stream) << int(v.type); + (*stream) << v.offset; + (*stream) << v.size; + (*stream) << v.arrayDims.count(); + for (int dim : v.arrayDims) + (*stream) << dim; + (*stream) << v.arrayStride; + (*stream) << v.matrixStride; + (*stream) << v.matrixIsRowMajor; + (*stream) << v.structMembers.count(); + for (const QShaderDescription::BlockVariable &sv : v.structMembers) + serializeBlockMemberVar(stream, sv); +} + QJsonDocument QShaderDescriptionPrivate::makeDoc() { QJsonObject root; @@ -1002,6 +1048,67 @@ QJsonDocument QShaderDescriptionPrivate::makeDoc() return QJsonDocument(root); } +void QShaderDescriptionPrivate::writeToStream(QDataStream *stream) +{ + (*stream) << inVars.count(); + for (const QShaderDescription::InOutVariable &v : qAsConst(inVars)) + serializeInOutVar(stream, v); + + (*stream) << outVars.count(); + for (const QShaderDescription::InOutVariable &v : qAsConst(outVars)) + serializeInOutVar(stream, v); + + (*stream) << uniformBlocks.count(); + for (const QShaderDescription::UniformBlock &b : uniformBlocks) { + (*stream) << b.blockName; + (*stream) << b.structName; + (*stream) << b.size; + (*stream) << b.binding; + (*stream) << b.descriptorSet; + (*stream) << b.members.count(); + for (const QShaderDescription::BlockVariable &v : b.members) + serializeBlockMemberVar(stream, v); + } + + (*stream) << pushConstantBlocks.count(); + for (const QShaderDescription::PushConstantBlock &b : pushConstantBlocks) { + (*stream) << b.name; + (*stream) << b.size; + (*stream) << b.members.count(); + for (const QShaderDescription::BlockVariable &v : b.members) + serializeBlockMemberVar(stream, v); + } + + (*stream) << storageBlocks.count(); + for (const QShaderDescription::StorageBlock &b : storageBlocks) { + (*stream) << b.blockName; + (*stream) << b.instanceName; + (*stream) << b.knownSize; + (*stream) << b.binding; + (*stream) << b.descriptorSet; + (*stream) << b.members.count(); + for (const QShaderDescription::BlockVariable &v : b.members) + serializeBlockMemberVar(stream, v); + } + + (*stream) << combinedImageSamplers.count(); + for (const QShaderDescription::InOutVariable &v : qAsConst(combinedImageSamplers)) { + (*stream) << v.name; + (*stream) << int(v.type); + serializeDecorations(stream, v); + } + + (*stream) << storageImages.count(); + for (const QShaderDescription::InOutVariable &v : qAsConst(storageImages)) { + (*stream) << v.name; + (*stream) << int(v.type); + serializeDecorations(stream, v); + } + + for (size_t i = 0; i < 3; ++i) + (*stream) << localSize[i]; +} + static QShaderDescription::InOutVariable inOutVar(const QJsonObject &obj) { QShaderDescription::InOutVariable var; @@ -1020,6 +1127,29 @@ static QShaderDescription::InOutVariable inOutVar(const QJsonObject &obj) return var; } +static void deserializeDecorations(QDataStream *stream, QShaderDescription::InOutVariable *v) +{ + (*stream) >> v->location; + (*stream) >> v->binding; + (*stream) >> v->descriptorSet; + int f; + (*stream) >> f; + v->imageFormat = QShaderDescription::ImageFormat(f); + (*stream) >> f; + v->imageFlags = QShaderDescription::ImageFlags(f); +} + +static QShaderDescription::InOutVariable deserializeInOutVar(QDataStream *stream) +{ + QShaderDescription::InOutVariable var; + (*stream) >> var.name; + int t; + (*stream) >> t; + var.type = QShaderDescription::VariableType(t); + deserializeDecorations(stream, &var); + return var; +} + static QShaderDescription::BlockVariable blockVar(const QJsonObject &obj) { QShaderDescription::BlockVariable var; @@ -1046,6 +1176,30 @@ static QShaderDescription::BlockVariable blockVar(const QJsonObject &obj) return var; } +static QShaderDescription::BlockVariable deserializeBlockMemberVar(QDataStream *stream) +{ + QShaderDescription::BlockVariable var; + (*stream) >> var.name; + int t; + (*stream) >> t; + var.type = QShaderDescription::VariableType(t); + (*stream) >> var.offset; + (*stream) >> var.size; + int count; + (*stream) >> count; + var.arrayDims.resize(count); + for (int i = 0; i < count; ++i) + (*stream) >> var.arrayDims[i]; + (*stream) >> var.arrayStride; + (*stream) >> var.matrixStride; + (*stream) >> var.matrixIsRowMajor; + (*stream) >> count; + var.structMembers.resize(count); + for (int i = 0; i < count; ++i) + var.structMembers[i] = deserializeBlockMemberVar(stream); + return var; +} + void QShaderDescriptionPrivate::loadDoc(const QJsonDocument &doc) { if (doc.isNull()) { @@ -1150,6 +1304,87 @@ void QShaderDescriptionPrivate::loadDoc(const QJsonDocument &doc) } } +void QShaderDescriptionPrivate::loadFromStream(QDataStream *stream) +{ + Q_ASSERT(ref.loadRelaxed() == 1); // must be detached + + int count; + (*stream) >> count; + inVars.resize(count); + for (int i = 0; i < count; ++i) + inVars[i] = deserializeInOutVar(stream); + + (*stream) >> count; + outVars.resize(count); + for (int i = 0; i < count; ++i) + outVars[i] = deserializeInOutVar(stream); + + (*stream) >> count; + uniformBlocks.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> uniformBlocks[i].blockName; + (*stream) >> uniformBlocks[i].structName; + (*stream) >> uniformBlocks[i].size; + (*stream) >> uniformBlocks[i].binding; + (*stream) >> uniformBlocks[i].descriptorSet; + int memberCount; + (*stream) >> memberCount; + uniformBlocks[i].members.resize(memberCount); + for (int memberIdx = 0; memberIdx < memberCount; ++memberIdx) + uniformBlocks[i].members[memberIdx] = deserializeBlockMemberVar(stream); + } + + (*stream) >> count; + pushConstantBlocks.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> pushConstantBlocks[i].name; + (*stream) >> pushConstantBlocks[i].size; + int memberCount; + (*stream) >> memberCount; + pushConstantBlocks[i].members.resize(memberCount); + for (int memberIdx = 0; memberIdx < memberCount; ++memberIdx) + pushConstantBlocks[i].members[memberIdx] = deserializeBlockMemberVar(stream); + } + + (*stream) >> count; + storageBlocks.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> storageBlocks[i].blockName; + (*stream) >> storageBlocks[i].instanceName; + (*stream) >> storageBlocks[i].knownSize; + (*stream) >> storageBlocks[i].binding; + (*stream) >> storageBlocks[i].descriptorSet; + int memberCount; + (*stream) >> memberCount; + storageBlocks[i].members.resize(memberCount); + for (int memberIdx = 0; memberIdx < memberCount; ++memberIdx) + storageBlocks[i].members[memberIdx] = deserializeBlockMemberVar(stream); + } + + (*stream) >> count; + combinedImageSamplers.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> combinedImageSamplers[i].name; + int t; + (*stream) >> t; + combinedImageSamplers[i].type = QShaderDescription::VariableType(t); + deserializeDecorations(stream, &combinedImageSamplers[i]); + } + + (*stream) >> count; + storageImages.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> storageImages[i].name; + int t; + (*stream) >> t; + storageImages[i].type = QShaderDescription::VariableType(t); + deserializeDecorations(stream, &storageImages[i]); + } + + for (size_t i = 0; i < 3; ++i) + (*stream) >> localSize[i]; +} + /*! Returns \c true if the two QShaderDescription objects \a lhs and \a rhs are equal. diff --git a/src/gui/rhi/qshaderdescription_p.h b/src/gui/rhi/qshaderdescription_p.h index 872ee8b138..108fc32a56 100644 --- a/src/gui/rhi/qshaderdescription_p.h +++ b/src/gui/rhi/qshaderdescription_p.h @@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE struct QShaderDescriptionPrivate; +class QDataStream; class Q_GUI_EXPORT QShaderDescription { @@ -69,6 +70,7 @@ public: bool isValid() const; QByteArray toCbor() const; + void serialize(QDataStream *stream) const; QByteArray toJson() const; #if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) @@ -76,6 +78,7 @@ public: static QShaderDescription fromBinaryJson(const QByteArray &data); #endif static QShaderDescription fromCbor(const QByteArray &data); + static QShaderDescription deserialize(QDataStream *stream); enum VariableType { Unknown = 0, diff --git a/src/gui/rhi/qshaderdescription_p_p.h b/src/gui/rhi/qshaderdescription_p_p.h index 1caee24984..69b6e811a1 100644 --- a/src/gui/rhi/qshaderdescription_p_p.h +++ b/src/gui/rhi/qshaderdescription_p_p.h @@ -80,7 +80,9 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate static const QShaderDescriptionPrivate *get(const QShaderDescription *desc) { return desc->d; } QJsonDocument makeDoc(); + void writeToStream(QDataStream *stream); void loadDoc(const QJsonDocument &doc); + void loadFromStream(QDataStream *stream); QAtomicInt ref; QVector inVars; -- cgit v1.2.3 From 0a93db4d82c051164923a10e4382b12de9049b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 8 Jan 2020 17:48:58 +0100 Subject: Unify application palette handling between QGuiApplication and QApplication The logic is now mostly handled in QGuiApplication, with QApplication only dealing with the widget-specific palettes and interaction between the style and the palette. The application now picks up changes to the platform theme and will re-resolve the current application palette appropriately. This also works even if an explicit application palette has been set, in which case any missing roles are filled in by the theme. The palette can now also be reset back to the default application palette that's fully based on the theme, by passing in the default constructed palette (or any palette that doesn't have any roles set). This is also correctly reflected in the Qt::AA_SetPalette attribute. Conceptually this means QGuiApplication and QApplication follow the same behavior as QWidget, where the palette falls back to a base or inherited palette for roles that are not set, in this case the theme. Behavior-wise this means that the default application palette of the application does not have any roles set, but clients should not have relied on this, nor does QWidget rely on that internally. It also means that setting a palette on the application and then getting it back again will not produce the same palette as set, since the palette was resolved against the theme in the meantime. This is the same behavior as for QWidget, and although it's a behavior change it's one towards a more sane behavior, so we accept it. [ChangeLog] Application palettes are now resolved against the platform's theme palette, the same way widget palettes are resolved against their parents, and the application palette. This means the application palette reflected through QGuiApplication::palette() may not be exactly the same palette as set via QGuiApplication::setPalette(). Change-Id: I76b99fcd27285e564899548349aa2a5713e5965d Reviewed-by: Vitaly Fanaskov Reviewed-by: Friedemann Kleint --- src/gui/kernel/qguiapplication.cpp | 117 +++++++++++++++++++++---------------- src/gui/kernel/qguiapplication_p.h | 11 +++- 2 files changed, 76 insertions(+), 52 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index ffd5b04276..445ad6b835 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -236,21 +236,6 @@ static bool qt_detectRTLLanguage() " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); } -static void initPalette() -{ - if (!QGuiApplicationPrivate::app_pal) - if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) - QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); - if (!QGuiApplicationPrivate::app_pal) - QGuiApplicationPrivate::app_pal = new QPalette(Qt::gray); -} - -static inline void clearPalette() -{ - delete QGuiApplicationPrivate::app_pal; - QGuiApplicationPrivate::app_pal = nullptr; -} - static void initFontUnlocked() { if (!QGuiApplicationPrivate::app_font) { @@ -691,7 +676,7 @@ QGuiApplication::~QGuiApplication() d->session_manager = nullptr; #endif //QT_NO_SESSIONMANAGER - clearPalette(); + QGuiApplicationPrivate::clearPalette(); QFontDatabase::removeAllApplicationFonts(); #ifndef QT_NO_CURSOR @@ -1611,7 +1596,7 @@ void QGuiApplicationPrivate::init() if (platform_integration == nullptr) createPlatformIntegration(); - initPalette(); + updatePalette(); QFont::initialize(); initThemeHints(); @@ -3289,46 +3274,97 @@ QClipboard * QGuiApplication::clipboard() */ /*! - Returns the default application palette. + Returns the current application palette. + + Roles that have not been explicitly set will reflect the system's platform theme. \sa setPalette() */ QPalette QGuiApplication::palette() { - initPalette(); + if (!QGuiApplicationPrivate::app_pal) + QGuiApplicationPrivate::updatePalette(); + return *QGuiApplicationPrivate::app_pal; } +void QGuiApplicationPrivate::updatePalette() +{ + if (app_pal) { + if (setPalette(*app_pal) && qGuiApp) + qGuiApp->d_func()->handlePaletteChanged(); + } else { + setPalette(QPalette()); + } +} + +void QGuiApplicationPrivate::clearPalette() +{ + delete app_pal; + app_pal = nullptr; +} + /*! - Changes the default application palette to \a pal. + Changes the application palette to \a pal. + + The color roles from this palette are combined with the system's platform + theme to form the application's final palette. \sa palette() */ void QGuiApplication::setPalette(const QPalette &pal) { - if (!QGuiApplicationPrivate::setPalette(pal)) - return; - - QCoreApplication::setAttribute(Qt::AA_SetPalette); - - if (qGuiApp) - qGuiApp->d_func()->sendApplicationPaletteChange(); + if (QGuiApplicationPrivate::setPalette(pal) && qGuiApp) + qGuiApp->d_func()->handlePaletteChanged(); } bool QGuiApplicationPrivate::setPalette(const QPalette &palette) { - if (app_pal && palette.isCopyOf(*app_pal)) + // Resolve the palette against the theme palette, filling in + // any missing roles, while keeping the original resolve mask. + QPalette basePalette = qGuiApp ? qGuiApp->d_func()->basePalette() : Qt::gray; + basePalette.resolve(0); // The base palette only contributes missing colors roles + QPalette resolvedPalette = palette.resolve(basePalette); + + if (app_pal && resolvedPalette == *app_pal && resolvedPalette.resolve() == app_pal->resolve()) return false; if (!app_pal) - app_pal = new QPalette(palette); + app_pal = new QPalette(resolvedPalette); else - *app_pal = palette; + *app_pal = resolvedPalette; + + QCoreApplication::setAttribute(Qt::AA_SetPalette, app_pal->resolve() != 0); return true; } +/* + Returns the base palette used to fill in missing roles in + the current application palette. + + Normally this is the theme palette, but QApplication + overrides this for compatibility reasons. +*/ +QPalette QGuiApplicationPrivate::basePalette() const +{ + return platformTheme() ? *platformTheme()->palette() : Qt::gray; +} + +void QGuiApplicationPrivate::handlePaletteChanged(const char *className) +{ + if (!className) { + Q_ASSERT(app_pal); + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + } + + if (is_app_running && !is_app_closing) { + QEvent event(QEvent::ApplicationPaletteChange); + QGuiApplication::sendEvent(qGuiApp, &event); + } +} + void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) { windowGeometrySpecification.applyTo(window); @@ -4127,11 +4163,8 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) void QGuiApplicationPrivate::notifyThemeChanged() { - if (!testAttribute(Qt::AA_SetPalette)) { - clearPalette(); - initPalette(); - sendApplicationPaletteChange(); - } + updatePalette(); + if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { const auto locker = qt_scoped_lock(applicationFontMutex); clearFontUnlocked(); @@ -4140,20 +4173,6 @@ void QGuiApplicationPrivate::notifyThemeChanged() initThemeHints(); } -void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) -{ - Q_UNUSED(toAllWidgets) - - if (!className) - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); - - if (!is_app_running || is_app_closing) - return; - - QEvent event(QEvent::ApplicationPaletteChange); - QGuiApplication::sendEvent(QGuiApplication::instance(), &event); -} - #if QT_CONFIG(draganddrop) void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) { diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 2fe4ae02cf..5239b58c97 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -323,17 +323,22 @@ public: static void resetCachedDevicePixelRatio(); - static bool setPalette(const QPalette &palette); - protected: virtual void notifyThemeChanged(); - virtual void sendApplicationPaletteChange(bool toAllWidgets = false, const char *className = nullptr); + + static bool setPalette(const QPalette &palette); + virtual QPalette basePalette() const; + virtual void handlePaletteChanged(const char *className = nullptr); + bool tryCloseRemainingWindows(QWindowList processedWindows); #if QT_CONFIG(draganddrop) virtual void notifyDragStarted(const QDrag *); #endif // QT_CONFIG(draganddrop) private: + static void clearPalette(); + static void updatePalette(); + friend class QDragManager; static QGuiApplicationPrivate *self; -- cgit v1.2.3 From 4772a2da15ae0624633f3fc4d029d5f0e1e33892 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 11 Dec 2019 12:20:06 +0100 Subject: Move QOpenGLWindow from QtGui to QtOpenGL Task-number: QTBUG-74409 Change-Id: If7d27cdfa2c6cd5b167887ad77b9cfe413cb106a Reviewed-by: Laszlo Agocs --- src/gui/kernel/kernel.pri | 6 +- src/gui/kernel/qopenglwindow.cpp | 698 --------------------------------------- src/gui/kernel/qopenglwindow.h | 107 ------ 3 files changed, 2 insertions(+), 809 deletions(-) delete mode 100644 src/gui/kernel/qopenglwindow.cpp delete mode 100644 src/gui/kernel/qopenglwindow.h (limited to 'src/gui') diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 3784abdacc..d47fd6e4e4 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -158,13 +158,11 @@ qtConfig(opengl) { HEADERS += \ kernel/qplatformopenglcontext.h \ kernel/qopenglcontext.h \ - kernel/qopenglcontext_p.h \ - kernel/qopenglwindow.h + kernel/qopenglcontext_p.h SOURCES += \ kernel/qplatformopenglcontext.cpp \ - kernel/qopenglcontext.cpp \ - kernel/qopenglwindow.cpp + kernel/qopenglcontext.cpp } qtConfig(shortcut) { diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp deleted file mode 100644 index 2ea8f43711..0000000000 --- a/src/gui/kernel/qopenglwindow.cpp +++ /dev/null @@ -1,698 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qopenglwindow.h" -#include "qpaintdevicewindow_p.h" -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QOpenGLWindow - \inmodule QtGui - \since 5.4 - \brief The QOpenGLWindow class is a convenience subclass of QWindow to perform OpenGL painting. - - QOpenGLWindow is an enhanced QWindow that allows easily creating windows that - perform OpenGL rendering using an API that is compatible with QOpenGLWidget - and is similar to the legacy QGLWidget. Unlike QOpenGLWidget, QOpenGLWindow - has no dependency on the widgets module and offers better performance. - - A typical application will subclass QOpenGLWindow and reimplement the following - virtual functions: - - \list - - \li initializeGL() to perform OpenGL resource initialization - - \li resizeGL() to set up the transformation matrices and other window size dependent resources - - \li paintGL() to issue OpenGL commands or draw using QPainter - - \endlist - - To schedule a repaint, call the update() function. Note that this will not - immediately result in a call to paintGL(). Calling update() multiple times in - a row will not change the behavior in any way. - - This is a slot so it can be connected to a \l QTimer::timeout() signal to - perform animation. Note however that in the modern OpenGL world it is a much - better choice to rely on synchronization to the vertical refresh rate of the - display. See \l{QSurfaceFormat::setSwapInterval()}{setSwapInterval()} on a - description of the swap interval. With a swap interval of \c 1, which is the - case on most systems by default, the - \l{QOpenGLContext::swapBuffers()}{swapBuffers()} call, that is executed - internally by QOpenGLWindow after each repaint, will block and wait for - vsync. This means that whenever the swap is done, an update can be scheduled - again by calling update(), without relying on timers. - - To request a specific configuration for the context, use setFormat() - like for any other QWindow. This allows, among others, requesting a - given OpenGL version and profile, or enabling depth and stencil - buffers. - - Unlike QWindow, QOpenGLWindow allows opening a painter on itself and perform - QPainter-based drawing. - - QOpenGLWindow supports multiple update behaviors. The default, - \c NoPartialUpdate is equivalent to a regular, OpenGL-based QWindow or the - legacy QGLWidget. In contrast, \c PartialUpdateBlit and \c PartialUpdateBlend are - more in line with QOpenGLWidget's way of working, where there is always an - extra, dedicated framebuffer object present. These modes allow, by - sacrificing some performance, redrawing only a smaller area on each paint and - having the rest of the content preserved from of the previous frame. This is - useful for applications than render incrementally using QPainter, because - this way they do not have to redraw the entire window content on each - paintGL() call. - - Similarly to QOpenGLWidget, QOpenGLWindow supports the Qt::AA_ShareOpenGLContexts - attribute. When enabled, the OpenGL contexts of all QOpenGLWindow instances will share - with each other. This allows accessing each other's shareable OpenGL resources. - - For more information on graphics in Qt, see \l {Graphics}. - */ - -/*! - \enum QOpenGLWindow::UpdateBehavior - - This enum describes the update strategy of the QOpenGLWindow. - - \value NoPartialUpdate Indicates that the entire window surface will - redrawn on each update and so no additional framebuffers are needed. - This is the setting used in most cases and is equivalent to how drawing - directly via QWindow would function. - - \value PartialUpdateBlit Indicates that the drawing performed in paintGL() - does not cover the entire window. In this case an extra framebuffer object - is created under the hood, and rendering performed in paintGL() will target - this framebuffer. This framebuffer is then blitted onto the window surface's - default framebuffer after each paint. This allows having QPainter-based drawing - code in paintGL() which only repaints a smaller area at a time, because, unlike - NoPartialUpdate, the previous content is preserved. - - \value PartialUpdateBlend Similar to PartialUpdateBlit, but instead of using - framebuffer blits, the contents of the extra framebuffer is rendered by - drawing a textured quad with blending enabled. This, unlike PartialUpdateBlit, - allows alpha blended content and works even when the glBlitFramebuffer is - not available. Performance-wise this setting is likely to be somewhat slower - than PartialUpdateBlit. - */ - -/*! - \fn void QOpenGLWindow::frameSwapped() - - This signal is emitted after the potentially blocking - \l{QOpenGLContext::swapBuffers()}{buffer swap} has been done. Applications - that wish to continuously repaint synchronized to the vertical refresh, - should issue an update() upon this signal. This allows for a much smoother - experience compared to the traditional usage of timers. -*/ - -// GLES2 builds won't have these constants with the suffixless names -#ifndef GL_READ_FRAMEBUFFER -#define GL_READ_FRAMEBUFFER 0x8CA8 -#endif -#ifndef GL_DRAW_FRAMEBUFFER -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#endif - -class QOpenGLWindowPaintDevice : public QOpenGLPaintDevice -{ -public: - QOpenGLWindowPaintDevice(QOpenGLWindow *window) : m_window(window) { } - void ensureActiveTarget() override; - - QOpenGLWindow *m_window; -}; - -class QOpenGLWindowPrivate : public QPaintDeviceWindowPrivate -{ - Q_DECLARE_PUBLIC(QOpenGLWindow) -public: - QOpenGLWindowPrivate(QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior) - : updateBehavior(updateBehavior) - , hasFboBlit(false) - , shareContext(shareContext) - { - if (!shareContext) - this->shareContext = qt_gl_global_share_context(); - } - - ~QOpenGLWindowPrivate(); - - static QOpenGLWindowPrivate *get(QOpenGLWindow *w) { return w->d_func(); } - - void bindFBO(); - void initialize(); - - void beginPaint(const QRegion ®ion) override; - void endPaint() override; - void flush(const QRegion ®ion) override; - - QOpenGLWindow::UpdateBehavior updateBehavior; - bool hasFboBlit; - QScopedPointer context; - QOpenGLContext *shareContext; - QScopedPointer fbo; - QScopedPointer paintDevice; - QOpenGLTextureBlitter blitter; - QColor backgroundColor; - QScopedPointer offscreenSurface; -}; - -QOpenGLWindowPrivate::~QOpenGLWindowPrivate() -{ - Q_Q(QOpenGLWindow); - if (q->isValid()) { - q->makeCurrent(); // this works even when the platformwindow is destroyed - paintDevice.reset(nullptr); - fbo.reset(nullptr); - blitter.destroy(); - q->doneCurrent(); - } -} - -void QOpenGLWindowPrivate::initialize() -{ - Q_Q(QOpenGLWindow); - - if (context) - return; - - if (!q->handle()) - qWarning("Attempted to initialize QOpenGLWindow without a platform window"); - - context.reset(new QOpenGLContext); - context->setShareContext(shareContext); - context->setFormat(q->requestedFormat()); - if (!context->create()) - qWarning("QOpenGLWindow::beginPaint: Failed to create context"); - if (!context->makeCurrent(q)) - qWarning("QOpenGLWindow::beginPaint: Failed to make context current"); - - paintDevice.reset(new QOpenGLWindowPaintDevice(q)); - if (updateBehavior == QOpenGLWindow::PartialUpdateBlit) - hasFboBlit = QOpenGLFramebufferObject::hasOpenGLFramebufferBlit(); - - q->initializeGL(); -} - -void QOpenGLWindowPrivate::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); - Q_Q(QOpenGLWindow); - - initialize(); - context->makeCurrent(q); - - const int deviceWidth = q->width() * q->devicePixelRatio(); - const int deviceHeight = q->height() * q->devicePixelRatio(); - const QSize deviceSize(deviceWidth, deviceHeight); - if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { - if (!fbo || fbo->size() != deviceSize) { - QOpenGLFramebufferObjectFormat fboFormat; - fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); - const int samples = q->requestedFormat().samples(); - if (samples > 0) { - if (updateBehavior != QOpenGLWindow::PartialUpdateBlend) - fboFormat.setSamples(samples); - else - qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling"); - } - fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat)); - markWindowAsDirty(); - } - } else { - markWindowAsDirty(); - } - - paintDevice->setSize(QSize(deviceWidth, deviceHeight)); - paintDevice->setDevicePixelRatio(q->devicePixelRatio()); - context->functions()->glViewport(0, 0, deviceWidth, deviceHeight); - - context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject()); - - q->paintUnderGL(); - - if (updateBehavior > QOpenGLWindow::NoPartialUpdate) - fbo->bind(); -} - -void QOpenGLWindowPrivate::endPaint() -{ - Q_Q(QOpenGLWindow); - - if (updateBehavior > QOpenGLWindow::NoPartialUpdate) - fbo->release(); - - context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject()); - - if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) { - const int deviceWidth = q->width() * q->devicePixelRatio(); - const int deviceHeight = q->height() * q->devicePixelRatio(); - QOpenGLExtensions extensions(context.data()); - extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle()); - extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject()); - extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight, - 0, 0, deviceWidth, deviceHeight, - GL_COLOR_BUFFER_BIT, GL_NEAREST); - } else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { - if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) { - context->functions()->glEnable(GL_BLEND); - context->functions()->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - if (!blitter.isCreated()) - blitter.create(); - - QRect windowRect(QPoint(0, 0), fbo->size()); - QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(windowRect, windowRect); - blitter.bind(); - blitter.blit(fbo->texture(), target, QOpenGLTextureBlitter::OriginBottomLeft); - blitter.release(); - - if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) - context->functions()->glDisable(GL_BLEND); - } - - q->paintOverGL(); -} - -void QOpenGLWindowPrivate::bindFBO() -{ - if (updateBehavior > QOpenGLWindow::NoPartialUpdate) - fbo->bind(); - else - QOpenGLFramebufferObject::bindDefault(); -} - -void QOpenGLWindowPrivate::flush(const QRegion ®ion) -{ - Q_UNUSED(region); - Q_Q(QOpenGLWindow); - context->swapBuffers(q); - emit q->frameSwapped(); -} - -void QOpenGLWindowPaintDevice::ensureActiveTarget() -{ - QOpenGLWindowPrivate::get(m_window)->bindFBO(); -} - -/*! - Constructs a new QOpenGLWindow with the given \a parent and \a updateBehavior. - - \sa QOpenGLWindow::UpdateBehavior - */ -QOpenGLWindow::QOpenGLWindow(QOpenGLWindow::UpdateBehavior updateBehavior, QWindow *parent) - : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(nullptr, updateBehavior)), parent) -{ - setSurfaceType(QSurface::OpenGLSurface); -} - -/*! - Constructs a new QOpenGLWindow with the given \a parent and \a updateBehavior. The QOpenGLWindow's context will share with \a shareContext. - - \sa QOpenGLWindow::UpdateBehavior shareContext -*/ -QOpenGLWindow::QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior, QWindow *parent) - : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(shareContext, updateBehavior)), parent) -{ - setSurfaceType(QSurface::OpenGLSurface); -} - -/*! - Destroys the QOpenGLWindow instance, freeing its resources. - - The OpenGLWindow's context is made current in the destructor, allowing for - safe destruction of any child object that may need to release OpenGL - resources belonging to the context provided by this window. - - \warning if you have objects wrapping OpenGL resources (such as - QOpenGLBuffer, QOpenGLShaderProgram, etc.) as members of a QOpenGLWindow - subclass, you may need to add a call to makeCurrent() in that subclass' - destructor as well. Due to the rules of C++ object destruction, those objects - will be destroyed \e{before} calling this function (but after that the - destructor of the subclass has run), therefore making the OpenGL context - current in this function happens too late for their safe disposal. - - \sa makeCurrent - - \since 5.5 -*/ -QOpenGLWindow::~QOpenGLWindow() -{ - makeCurrent(); -} - -/*! - \return the update behavior for this QOpenGLWindow. -*/ -QOpenGLWindow::UpdateBehavior QOpenGLWindow::updateBehavior() const -{ - Q_D(const QOpenGLWindow); - return d->updateBehavior; -} - -/*! - \return \c true if the window's OpenGL resources, like the context, have - been successfully initialized. Note that the return value is always \c false - until the window becomes exposed (shown). -*/ -bool QOpenGLWindow::isValid() const -{ - Q_D(const QOpenGLWindow); - return d->context && d->context->isValid(); -} - -/*! - Prepares for rendering OpenGL content for this window by making the - corresponding context current and binding the framebuffer object, if there is - one, in that context context. - - It is not necessary to call this function in most cases, because it is called - automatically before invoking paintGL(). It is provided nonetheless to support - advanced, multi-threaded scenarios where a thread different than the GUI or main - thread may want to update the surface or framebuffer contents. See QOpenGLContext - for more information on threading related issues. - - This function is suitable for calling also when the underlying platform window - is already destroyed. This means that it is safe to call this function from - a QOpenGLWindow subclass' destructor. If there is no native window anymore, - an offscreen surface is used instead. This ensures that OpenGL resource - cleanup operations in the destructor will always work, as long as - this function is called first. - - \sa QOpenGLContext, context(), paintGL(), doneCurrent() - */ -void QOpenGLWindow::makeCurrent() -{ - Q_D(QOpenGLWindow); - - if (!isValid()) - return; - - // The platform window may be destroyed at this stage and therefore - // makeCurrent() may not safely be called with 'this'. - if (handle()) { - d->context->makeCurrent(this); - } else { - if (!d->offscreenSurface) { - d->offscreenSurface.reset(new QOffscreenSurface(screen())); - d->offscreenSurface->setFormat(d->context->format()); - d->offscreenSurface->create(); - } - d->context->makeCurrent(d->offscreenSurface.data()); - } - - d->bindFBO(); -} - -/*! - Releases the context. - - It is not necessary to call this function in most cases, since the widget - will make sure the context is bound and released properly when invoking - paintGL(). - - \sa makeCurrent() - */ -void QOpenGLWindow::doneCurrent() -{ - Q_D(QOpenGLWindow); - - if (!isValid()) - return; - - d->context->doneCurrent(); -} - -/*! - \return The QOpenGLContext used by this window or \c 0 if not yet initialized. - */ -QOpenGLContext *QOpenGLWindow::context() const -{ - Q_D(const QOpenGLWindow); - return d->context.data(); -} - -/*! - \return The QOpenGLContext requested to be shared with this window's QOpenGLContext. -*/ -QOpenGLContext *QOpenGLWindow::shareContext() const -{ - Q_D(const QOpenGLWindow); - return d->shareContext; -} - -/*! - The framebuffer object handle used by this window. - - When the update behavior is set to \c NoPartialUpdate, there is no separate - framebuffer object. In this case the returned value is the ID of the - default framebuffer. - - Otherwise the value of the ID of the framebuffer object or \c 0 if not - yet initialized. - */ -GLuint QOpenGLWindow::defaultFramebufferObject() const -{ - Q_D(const QOpenGLWindow); - if (d->updateBehavior > NoPartialUpdate && d->fbo) - return d->fbo->handle(); - else if (QOpenGLContext *ctx = QOpenGLContext::currentContext()) - return ctx->defaultFramebufferObject(); - else - return 0; -} - -extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); - -/*! - Returns a copy of the framebuffer. - - \note This is a potentially expensive operation because it relies on - glReadPixels() to read back the pixels. This may be slow and can stall the - GPU pipeline. - - \note When used together with update behavior \c NoPartialUpdate, the returned - image may not contain the desired content when called after the front and back - buffers have been swapped (unless preserved swap is enabled in the underlying - windowing system interface). In this mode the function reads from the back - buffer and the contents of that may not match the content on the screen (the - front buffer). In this case the only place where this function can safely be - used is paintGL() or paintOverGL(). - */ -QImage QOpenGLWindow::grabFramebuffer() -{ - if (!isValid()) - return QImage(); - - makeCurrent(); - - const bool hasAlpha = format().hasAlpha(); - QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), hasAlpha, hasAlpha); - img.setDevicePixelRatio(devicePixelRatio()); - return img; -} - -/*! - This virtual function is called once before the first call to paintGL() or - resizeGL(). Reimplement it in a subclass. - - This function should set up any required OpenGL resources and state. - - There is no need to call makeCurrent() because this has already been done - when this function is called. Note however that the framebuffer, in case - partial update mode is used, is not yet available at this stage, so avoid - issuing draw calls from here. Defer such calls to paintGL() instead. - - \sa paintGL(), resizeGL() - */ -void QOpenGLWindow::initializeGL() -{ -} - -/*! - This virtual function is called whenever the widget has been resized. - Reimplement it in a subclass. The new size is passed in \a w and \a h. - - \note This is merely a convenience function in order to provide an API that is - compatible with QOpenGLWidget. Unlike with QOpenGLWidget, derived classes are - free to choose to override resizeEvent() instead of this function. - - \note Avoid issuing OpenGL commands from this function as there may not be a - context current when it is invoked. If it cannot be avoided, call makeCurrent(). - - \note Scheduling updates from here is not necessary. The windowing systems - will send expose events that trigger an update automatically. - - \sa initializeGL(), paintGL() - */ -void QOpenGLWindow::resizeGL(int w, int h) -{ - Q_UNUSED(w); - Q_UNUSED(h); -} - -/*! - This virtual function is called whenever the window contents needs to be - painted. Reimplement it in a subclass. - - There is no need to call makeCurrent() because this has already - been done when this function is called. - - Before invoking this function, the context and the framebuffer, if there is - one, are bound, and the viewport is set up by a call to glViewport(). No - other state is set and no clearing or drawing is performed by the framework. - - \note When using a partial update behavior, like \c PartialUpdateBlend, the - output of the previous paintGL() call is preserved and, after the additional - drawing perfomed in the current invocation of the function, the content is - blitted or blended over the content drawn directly to the window in - paintUnderGL(). - - \sa initializeGL(), resizeGL(), paintUnderGL(), paintOverGL(), UpdateBehavior - */ -void QOpenGLWindow::paintGL() -{ -} - -/*! - The virtual function is called before each invocation of paintGL(). - - When the update mode is set to \c NoPartialUpdate, there is no difference - between this function and paintGL(), performing rendering in either of them - leads to the same result. - - The difference becomes significant when using \c PartialUpdateBlend, where an - extra framebuffer object is used. There, paintGL() targets this additional - framebuffer object, which preserves its contents, while paintUnderGL() and - paintOverGL() target the default framebuffer, i.e. directly the window - surface, the contents of which is lost after each displayed frame. - - \note Avoid relying on this function when the update behavior is - \c PartialUpdateBlit. This mode involves blitting the extra framebuffer used by - paintGL() onto the default framebuffer after each invocation of paintGL(), - thus overwriting all drawing generated in this function. - - \sa paintGL(), paintOverGL(), UpdateBehavior - */ -void QOpenGLWindow::paintUnderGL() -{ -} - -/*! - This virtual function is called after each invocation of paintGL(). - - When the update mode is set to NoPartialUpdate, there is no difference - between this function and paintGL(), performing rendering in either of them - leads to the same result. - - Like paintUnderGL(), rendering in this function targets the default - framebuffer of the window, regardless of the update behavior. It gets called - after paintGL() has returned and the blit (PartialUpdateBlit) or quad drawing - (PartialUpdateBlend) has been done. - - \sa paintGL(), paintUnderGL(), UpdateBehavior - */ -void QOpenGLWindow::paintOverGL() -{ -} - -/*! - Paint \a event handler. Calls paintGL(). - - \sa paintGL() - */ -void QOpenGLWindow::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - paintGL(); -} - -/*! - Resize \a event handler. Calls resizeGL(). - - \sa resizeGL() - */ -void QOpenGLWindow::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - Q_D(QOpenGLWindow); - d->initialize(); - resizeGL(width(), height()); -} - -/*! - \internal - */ -int QOpenGLWindow::metric(PaintDeviceMetric metric) const -{ - Q_D(const QOpenGLWindow); - - switch (metric) { - case PdmDepth: - if (d->paintDevice) - return d->paintDevice->depth(); - break; - default: - break; - } - return QPaintDeviceWindow::metric(metric); -} - -/*! - \internal - */ -QPaintDevice *QOpenGLWindow::redirected(QPoint *) const -{ - Q_D(const QOpenGLWindow); - if (QOpenGLContext::currentContext() == d->context.data()) - return d->paintDevice.data(); - return nullptr; -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qopenglwindow.h b/src/gui/kernel/qopenglwindow.h deleted file mode 100644 index 7b3bf004a3..0000000000 --- a/src/gui/kernel/qopenglwindow.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLWINDOW_H -#define QOPENGLWINDOW_H - -#include - -#ifndef QT_NO_OPENGL - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QOpenGLWindowPrivate; - -class Q_GUI_EXPORT QOpenGLWindow : public QPaintDeviceWindow -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QOpenGLWindow) - -public: - enum UpdateBehavior { - NoPartialUpdate, - PartialUpdateBlit, - PartialUpdateBlend - }; - - explicit QOpenGLWindow(UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = nullptr); - explicit QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = nullptr); - ~QOpenGLWindow(); - - UpdateBehavior updateBehavior() const; - bool isValid() const; - - void makeCurrent(); - void doneCurrent(); - - QOpenGLContext *context() const; - QOpenGLContext *shareContext() const; - - GLuint defaultFramebufferObject() const; - - QImage grabFramebuffer(); - -Q_SIGNALS: - void frameSwapped(); - -protected: - virtual void initializeGL(); - virtual void resizeGL(int w, int h); - virtual void paintGL(); - virtual void paintUnderGL(); - virtual void paintOverGL(); - - void paintEvent(QPaintEvent *event) override; - void resizeEvent(QResizeEvent *event) override; - int metric(PaintDeviceMetric metric) const override; - QPaintDevice *redirected(QPoint *) const override; - -private: - Q_DISABLE_COPY(QOpenGLWindow) -}; - -QT_END_NAMESPACE - -#endif // QT_NO_OPENGL - -#endif -- cgit v1.2.3 From 63b0b857f3cc84315a10c9b6d988bd657e7ce998 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Thu, 16 Jan 2020 17:21:15 +0100 Subject: QPalette: fix function swap and move operator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additional data should also be taken into account when using move operator and function swap. This is already implemented for move constructor. Task-number: QTBUG-78544 Change-Id: I24ba34b0957a8fba7e15a934f2d08222dc95650f Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qpalette.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index c95640d383..fd0ef2e2d9 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -72,11 +72,12 @@ public: { other.d = nullptr; } inline QPalette &operator=(QPalette &&other) noexcept { - qSwap(d, other.d); return *this; + swap(other); return *this; } void swap(QPalette &other) noexcept { + qSwap(data, other.data); qSwap(d, other.d); } -- cgit v1.2.3 From a3b2eac380bcd7d787e8fcc92a27bd7ed4f80b55 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 16 Jan 2020 11:18:21 +0100 Subject: QColor: add casts to ushort Silence lossy conversion warnings on MSVC. Task-number: QTBUG-80997 Change-Id: I0e5778b9f20b599de6fc8894c4b98fbc1b1510b9 Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qcolor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index f0d7dd23ad..0189f4e5f1 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -72,10 +72,10 @@ public: QColor(Qt::GlobalColor color) noexcept; Q_DECL_CONSTEXPR QColor(int r, int g, int b, int a = 255) noexcept : cspec(isRgbaValid(r, g, b, a) ? Rgb : Invalid), - ct(cspec == Rgb ? a * 0x0101 : 0, - cspec == Rgb ? r * 0x0101 : 0, - cspec == Rgb ? g * 0x0101 : 0, - cspec == Rgb ? b * 0x0101 : 0, + ct(ushort(cspec == Rgb ? a * 0x0101 : 0), + ushort(cspec == Rgb ? r * 0x0101 : 0), + ushort(cspec == Rgb ? g * 0x0101 : 0), + ushort(cspec == Rgb ? b * 0x0101 : 0), 0) {} QColor(QRgb rgb) noexcept; QColor(QRgba64 rgba64) noexcept; -- cgit v1.2.3 From 28f95d4688c28f8c06aa103012c6a00e197db12c Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 15 Jan 2020 14:38:14 +0100 Subject: Doc: Fix qdoc compilation errors qtbase Task-number: QTBUG-79824 Change-Id: I5a39525e3e735415ba96e2d585c5de754deb15de Reviewed-by: Venugopal Shivashankar --- src/gui/doc/qtgui.qdocconf | 1 + src/gui/kernel/qwindow.cpp | 1 - src/gui/painting/qbackingstore.cpp | 2 -- src/gui/painting/qpainter.cpp | 3 +-- src/gui/rhi/qrhimetal.mm | 2 +- 5 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf index 76dd6d7ea1..d149caf069 100644 --- a/src/gui/doc/qtgui.qdocconf +++ b/src/gui/doc/qtgui.qdocconf @@ -41,6 +41,7 @@ depends += \ qtwidgets \ qtdoc \ qmake \ + qtcmake \ qttestlib headerdirs += .. diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index f701755500..0a4277c118 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2690,7 +2690,6 @@ QOpenGLContext *QWindowPrivate::shareContext() const platform dependent and untested. \sa setParent() - \sa setTransientParent() */ QWindow *QWindow::fromWinId(WId id) { diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index b0393aff95..0a49269c36 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -220,8 +220,6 @@ static bool isRasterSurface(QWindow *window) to the backingstore's top level window. You should call this function after ending painting with endPaint(). - - \sa QWindow::transientParent() */ void QBackingStore::flush(const QRegion ®ion, QWindow *window, const QPoint &offset) { diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3ce54c20be..75e7dc49fd 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1404,8 +1404,7 @@ void QPainterPrivate::updateState(QPainterState *newState) cases where expensive operations are ok to use, for instance when the result is cached in a QPixmap. - \sa QPaintDevice, QPaintEngine, {Qt SVG}, {Basic Drawing Example}, - {Drawing Utility Functions} + \sa QPaintDevice, QPaintEngine, {Qt SVG}, {Basic Drawing Example}, {}{Drawing Utility Functions} */ /*! diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 3ecc56d147..83fec31081 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -129,7 +129,7 @@ QT_BEGIN_NAMESPACE recording a frame, that is, between a \l{QRhi::beginFrame()}{beginFrame()} - \l{QRhi::endFrame()}{endFrame()} or \l{QRhi::beginOffscreenFrame()}{beginOffscreenFrame()} - - \l{QRhi::endOffsrceenFrame()}{endOffscreenFrame()} pair. + \l{QRhi::endOffscreenFrame()}{endOffsrceenFrame()} pair. \note The command encoder is only valid while recording a pass, that is, between \l{QRhiCommandBuffer::beginPass()} - -- cgit v1.2.3 From 9c172af7d5d8696a692fb2e040be11eae99a4b0c Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Mon, 23 Jul 2018 10:01:23 +0200 Subject: Doc: Update text that refers to deprecated member function width() * Add see also links from the deprecated function to the replacement. * Change introduction text to reflect new function name rather than the old and deprecated width(). * Change see also and inline references to width(), so that they now refer to horizontalAdvance(). Task-number: QTBUG-65141 Change-Id: Iadfbc517e5df96e32058516f8795bd210cc4c5e4 Reviewed-by: Nico Vertriest Reviewed-by: Venugopal Shivashankar --- src/gui/text/qfontmetrics.cpp | 70 +++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 33 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index d3e4f11e8c..b7a3066f3a 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -106,12 +106,12 @@ extern void qt_format_text(const QFont& font, const QRectF &_r, These are by necessity slow, and we recommend avoiding them if possible. - For each character, you can get its width(), leftBearing() and - rightBearing() and find out whether it is in the font using + For each character, you can get its horizontalAdvance(), leftBearing(), + and rightBearing(), and find out whether it is in the font using inFont(). You can also treat the character as a string, and use the string functions on it. - The string functions include width(), to return the width of a + The string functions include horizontalAdvance(), to return the width of a string in pixels (or points, for a printer), boundingRect(), to return a rectangle large enough to contain the rendered string, and size(), to return the size of that rectangle. @@ -464,9 +464,9 @@ bool QFontMetrics::inFontUcs4(uint ucs4) const value is negative if the pixels of the character extend to the left of the logical origin. - See width() for a graphical description of this metric. + See horizontalAdvance() for a graphical description of this metric. - \sa rightBearing(), minLeftBearing(), width() + \sa rightBearing(), minLeftBearing(), horizontalAdvance() */ int QFontMetrics::leftBearing(QChar ch) const { @@ -495,11 +495,11 @@ int QFontMetrics::leftBearing(QChar ch) const The right bearing is the left-ward distance of the right-most pixel of the character from the logical origin of a subsequent character. This value is negative if the pixels of the character - extend to the right of the width() of the character. + extend to the right of the horizontalAdvance() of the character. - See width() for a graphical description of this metric. + See horizontalAdvance() for a graphical description of this metric. - \sa leftBearing(), minRightBearing(), width() + \sa leftBearing(), minRightBearing(), horizontalAdvance() */ int QFontMetrics::rightBearing(QChar ch) const { @@ -535,7 +535,7 @@ int QFontMetrics::rightBearing(QChar ch) const \deprecated in Qt 5.11. Use horizontalAdvance() instead. - \sa boundingRect() + \sa boundingRect(), horizontalAdvance() */ int QFontMetrics::width(const QString &text, int len) const { @@ -601,7 +601,7 @@ int QFontMetrics::width(const QString &text, int len, int flags) const processing strings cannot be taken into account. When implementing an interactive text control, use QTextLayout instead. - \sa boundingRect() + \sa boundingRect(), horizontalAdvance() */ int QFontMetrics::width(QChar ch) const { @@ -751,7 +751,8 @@ int QFontMetrics::charWidth(const QString &text, int pos) const Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned - rectangle might be different than what the width() method returns. + rectangle might be different than what the horizontalAdvance() method + returns. If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead. @@ -762,7 +763,8 @@ int QFontMetrics::charWidth(const QString &text, int pos) const The height of the bounding rectangle is at least as large as the value returned by height(). - \sa width(), height(), QPainter::boundingRect(), tightBoundingRect() + \sa horizontalAdvance(), height(), QPainter::boundingRect(), + tightBoundingRect() */ QRect QFontMetrics::boundingRect(const QString &text) const { @@ -790,7 +792,7 @@ QRect QFontMetrics::boundingRect(const QString &text) const \warning The width of the returned rectangle is not the advance width of the character. Use boundingRect(const QString &) or horizontalAdvance() instead. - \sa width() + \sa horizontalAdvance() */ QRect QFontMetrics::boundingRect(QChar ch) const { @@ -864,7 +866,7 @@ QRect QFontMetrics::boundingRect(QChar ch) const fontHeight() and lineSpacing() are used to calculate the height, rather than individual character heights. - \sa width(), QPainter::boundingRect(), Qt::Alignment + \sa horizontalAdvance(), QPainter::boundingRect(), Qt::Alignment */ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &text, int tabStops, int *tabArray) const @@ -920,7 +922,8 @@ QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabA Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned - rectangle might be different than what the width() method returns. + rectangle might be different than what the horizontalAdvance() method + returns. If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead. @@ -930,7 +933,7 @@ QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabA \warning Calling this method is very slow on Windows. - \sa width(), height(), boundingRect() + \sa horizontalAdvance(), height(), boundingRect() */ QRect QFontMetrics::tightBoundingRect(const QString &text) const { @@ -1079,12 +1082,12 @@ qreal QFontMetrics::fontDpi() const These are by necessity slow, and we recommend avoiding them if possible. - For each character, you can get its width(), leftBearing() and - rightBearing() and find out whether it is in the font using + For each character, you can get its horizontalAdvance(), leftBearing(), and + rightBearing(), and find out whether it is in the font using inFont(). You can also treat the character as a string, and use the string functions on it. - The string functions include width(), to return the width of a + The string functions include horizontalAdvance(), to return the width of a string in pixels (or points, for a printer), boundingRect(), to return a rectangle large enough to contain the rendered string, and size(), to return the size of that rectangle. @@ -1434,9 +1437,9 @@ bool QFontMetricsF::inFontUcs4(uint ucs4) const value is negative if the pixels of the character extend to the left of the logical origin. - See width() for a graphical description of this metric. + See horizontalAdvance() for a graphical description of this metric. - \sa rightBearing(), minLeftBearing(), width() + \sa rightBearing(), minLeftBearing(), horizontalAdvance() */ qreal QFontMetricsF::leftBearing(QChar ch) const { @@ -1465,11 +1468,11 @@ qreal QFontMetricsF::leftBearing(QChar ch) const The right bearing is the left-ward distance of the right-most pixel of the character from the logical origin of a subsequent character. This value is negative if the pixels of the character - extend to the right of the width() of the character. + extend to the right of the horizontalAdvance() of the character. - See width() for a graphical description of this metric. + See horizontalAdvance() for a graphical description of this metric. - \sa leftBearing(), minRightBearing(), width() + \sa leftBearing(), minRightBearing(), horizontalAdvance() */ qreal QFontMetricsF::rightBearing(QChar ch) const { @@ -1504,7 +1507,7 @@ qreal QFontMetricsF::rightBearing(QChar ch) const \deprecated in Qt 5.11. Use horizontalAdvance() instead. - \sa boundingRect() + \sa boundingRect(), horizontalAdvance() */ qreal QFontMetricsF::width(const QString &text) const { @@ -1535,7 +1538,7 @@ qreal QFontMetricsF::width(const QString &text) const processing strings cannot be taken into account. When implementing an interactive text control, use QTextLayout instead. - \sa boundingRect() + \sa boundingRect(), horizontalAdvance() */ qreal QFontMetricsF::width(QChar ch) const { @@ -1581,7 +1584,7 @@ qreal QFontMetricsF::horizontalAdvance(const QString &text, int length) const ch. Some of the metrics are described in the image to the right. The - central dark rectangles cover the logical width() of each + central dark rectangles cover the logical horizontalAdvance() of each character. The outer pale rectangles cover the leftBearing() and rightBearing() of each character. Notice that the bearings of "f" in this particular font are both negative, while the bearings of @@ -1632,7 +1635,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned - rectangle might be different than what the width() method returns. + rectangle might be different than what the horizontalAdvance() method returns. If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead. @@ -1643,7 +1646,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const The height of the bounding rectangle is at least as large as the value returned height(). - \sa width(), height(), QPainter::boundingRect() + \sa horizontalAdvance(), height(), QPainter::boundingRect() */ QRectF QFontMetricsF::boundingRect(const QString &text) const { @@ -1669,7 +1672,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const Note that the rectangle usually extends both above and below the base line. - \sa width() + \sa horizontalAdvance() */ QRectF QFontMetricsF::boundingRect(QChar ch) const { @@ -1746,7 +1749,7 @@ QRectF QFontMetricsF::boundingRect(QChar ch) const fontHeight() and lineSpacing() are used to calculate the height, rather than individual character heights. - \sa width(), QPainter::boundingRect(), Qt::Alignment + \sa horizontalAdvance(), QPainter::boundingRect(), Qt::Alignment */ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString& text, int tabStops, int *tabArray) const @@ -1805,7 +1808,8 @@ QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *ta Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned - rectangle might be different than what the width() method returns. + rectangle might be different than what the horizontalAdvance() method + returns. If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead. @@ -1815,7 +1819,7 @@ QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *ta \warning Calling this method is very slow on Windows. - \sa width(), height(), boundingRect() + \sa horizontalAdvance(), height(), boundingRect() */ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const { -- cgit v1.2.3 From 06bb315beb6c2c398223cfe52cbc7f66e14a8557 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 12 Dec 2019 12:58:11 +0100 Subject: Remove QOpenGLTextureHelper dependency from QOpenGLContext It's now just a pointer to a forward declared class Task-number: QTBUG-74409 Change-Id: I34df385154dcff2bbba2f6318825ab5258fa6695 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qopenglcontext.cpp | 10 ++++++---- src/gui/kernel/qopenglcontext.h | 2 +- src/gui/kernel/qopenglcontext_p.h | 1 + src/gui/opengl/qopengltexture.cpp | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 124b39f2a9..ab71434c13 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -56,8 +56,6 @@ #include #include -#include - #include #ifndef QT_OPENGL_ES_2 @@ -664,7 +662,10 @@ void QOpenGLContext::destroy() qDeleteAll(d->versionFunctions); d->versionFunctions.clear(); - delete d->textureFunctions; + if (d->textureFunctionsDestroyCallback) { + d->textureFunctionsDestroyCallback(); + d->textureFunctionsDestroyCallback = nullptr; + } d->textureFunctions = nullptr; d->nativeHandle = QVariant(); @@ -1388,10 +1389,11 @@ QOpenGLTextureHelper* QOpenGLContext::textureFunctions() const /*! \internal */ -void QOpenGLContext::setTextureFunctions(QOpenGLTextureHelper* textureFuncs) +void QOpenGLContext::setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function destroyCallback) { Q_D(QOpenGLContext); d->textureFunctions = textureFuncs; + d->textureFunctionsDestroyCallback = destroyCallback; } /*! diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h index 9cfaa52f17..f19dde465a 100644 --- a/src/gui/kernel/qopenglcontext.h +++ b/src/gui/kernel/qopenglcontext.h @@ -243,7 +243,7 @@ private: void removeExternalFunctions(QAbstractOpenGLFunctions *f); QOpenGLTextureHelper* textureFunctions() const; - void setTextureFunctions(QOpenGLTextureHelper* textureFuncs); + void setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function destroyCallback); void destroy(); diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 833cfb20c3..7770b1ce02 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -240,6 +240,7 @@ public: QOpenGLFunctions *functions; mutable QSet extensionNames; QOpenGLTextureHelper* textureFunctions; + std::function textureFunctionsDestroyCallback; GLint max_texture_size; diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index fd282e3ba0..35d90898e5 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -151,7 +151,8 @@ void QOpenGLTexturePrivate::initializeOpenGLFunctions() texFuncs = context->textureFunctions(); if (!texFuncs) { texFuncs = new QOpenGLTextureHelper(context); - context->setTextureFunctions(texFuncs); + auto *funcs = texFuncs; // lets us capture by pointer value below + context->setTextureFunctions(funcs, [funcs] { delete funcs; }); } } -- cgit v1.2.3