From a547404c12b50b8c9ab6a078fce5ce9a7300586f Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 18 Feb 2019 13:09:58 +0100 Subject: QTextureFileReader: backport ASTC support Add support for astc format files as an experimental feature. To enable, configure with "-feature-texture_format_astc_experimental" (Backported from commit 5a4db421bd94acd12a4ac1f77031996b95f85dbf) Change-Id: I9a2f7b1fa20ba344b79637bafb50ff2bd0596747 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/configure.json | 5 ++ src/gui/util/qastchandler.cpp | 168 ++++++++++++++++++++++++++++++++++++ src/gui/util/qastchandler_p.h | 73 ++++++++++++++++ src/gui/util/qtexturefilereader.cpp | 10 ++- src/gui/util/util.pri | 5 ++ 5 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 src/gui/util/qastchandler.cpp create mode 100644 src/gui/util/qastchandler_p.h (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index c51e3ceee3..6dd6f5b16c 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1748,6 +1748,11 @@ "section": "Images", "output": [ "publicFeature", "feature" ] }, + "texture_format_astc_experimental" : { + "label": "ASTC Texture format (experimental)", + "autoDetect": "false", + "output": [ "privateFeature" ] + }, "picture": { "label": "QPicture", "purpose": "Supports recording and replaying QPainter commands.", diff --git a/src/gui/util/qastchandler.cpp b/src/gui/util/qastchandler.cpp new file mode 100644 index 0000000000..6d163c6701 --- /dev/null +++ b/src/gui/util/qastchandler.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "qastchandler_p.h" +#include "qtexturefiledata_p.h" + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +struct AstcHeader +{ + quint8 magic[4]; + quint8 blockDimX; + quint8 blockDimY; + quint8 blockDimZ; + quint8 xSize[3]; + quint8 ySize[3]; + quint8 zSize[3]; +}; + +bool QAstcHandler::canRead(const QByteArray &suffix, const QByteArray &block) +{ + Q_UNUSED(suffix) + + return block.startsWith("\x13\xAB\xA1\x5C"); +} + +quint32 QAstcHandler::astcGLFormat(quint8 xBlockDim, quint8 yBlockDim) const +{ + static const quint32 glFormatRGBABase = 0x93B0; // GL_COMPRESSED_RGBA_ASTC_4x4_KHR + static const quint32 glFormatSRGBBase = 0x93D0; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR + + static QSize dims[14] = { + { 4, 4 }, // GL_COMPRESSED_xxx_ASTC_4x4_KHR + { 5, 4 }, // GL_COMPRESSED_xxx_ASTC_5x4_KHR + { 5, 5 }, // GL_COMPRESSED_xxx_ASTC_5x5_KHR + { 6, 5 }, // GL_COMPRESSED_xxx_ASTC_6x5_KHR + { 6, 6 }, // GL_COMPRESSED_xxx_ASTC_6x6_KHR + { 8, 5 }, // GL_COMPRESSED_xxx_ASTC_8x5_KHR + { 8, 6 }, // GL_COMPRESSED_xxx_ASTC_8x6_KHR + { 8, 8 }, // GL_COMPRESSED_xxx_ASTC_8x8_KHR + { 10, 5 }, // GL_COMPRESSED_xxx_ASTC_10x5_KHR + { 10, 6 }, // GL_COMPRESSED_xxx_ASTC_10x6_KHR + { 10, 8 }, // GL_COMPRESSED_xxx_ASTC_10x8_KHR + { 10, 10 }, // GL_COMPRESSED_xxx_ASTC_10x10_KHR + { 12, 10 }, // GL_COMPRESSED_xxx_ASTC_12x10_KHR + { 12, 12 } // GL_COMPRESSED_xxx_ASTC_12x12_KHR + }; + + const QSize dim(xBlockDim, yBlockDim); + int index = -1; + for (int i = 0; i < 14; i++) { + if (dim == dims[i]) { + index = i; + break; + } + } + if (index < 0) + return 0; + + bool useSrgb = qEnvironmentVariableIsSet("QT_ASTCHANDLER_USE_SRGB") + || logName().toLower().contains("srgb"); + + return useSrgb ? (glFormatSRGBBase + index) : (glFormatRGBABase + index); +} + +QTextureFileData QAstcHandler::read() +{ + QTextureFileData nullData; + QTextureFileData res; + + if (!device()) + return nullData; + + QByteArray fileData = device()->readAll(); + if (fileData.size() < int(sizeof(AstcHeader)) || !canRead(QByteArray(), fileData)) { + qCDebug(lcQtGuiTextureIO, "Not an ASTC file: %s", logName().constData()); + return nullData; + } + res.setData(fileData); + + const AstcHeader *header = reinterpret_cast(fileData.constData()); + + int xSz = int(header->xSize[0]) | int(header->xSize[1]) << 8 | int(header->xSize[2]) << 16; + int ySz = int(header->ySize[0]) | int(header->ySize[1]) << 8 | int(header->ySize[2]) << 16; + int zSz = int(header->zSize[0]) | int(header->zSize[1]) << 8 | int(header->zSize[2]) << 16; + + quint32 glFmt = astcGLFormat(header->blockDimX, header->blockDimY); + + if (!xSz || !ySz || !zSz || !glFmt || header->blockDimZ != 1) { + qCDebug(lcQtGuiTextureIO, "Invalid ASTC header data in file %s", logName().constData()); + return nullData; + } + + res.setSize(QSize(xSz, ySz)); + res.setGLFormat(0); // 0 for compressed textures + res.setGLInternalFormat(glFmt); + //? BaseInternalFormat + + int xBlocks = (xSz + header->blockDimX - 1) / header->blockDimX; + int yBlocks = (ySz + header->blockDimY - 1) / header->blockDimY; + int zBlocks = (zSz + header->blockDimZ - 1) / header->blockDimZ; + + int byteCount = 0; + bool oob = mul_overflow(xBlocks, yBlocks, &byteCount) + || mul_overflow(byteCount, zBlocks, &byteCount) + || mul_overflow(byteCount, 16, &byteCount); + + + res.setDataOffset(sizeof(AstcHeader)); + res.setNumLevels(1); + res.setDataLength(byteCount); + + if (oob || !res.isValid()) { + qCDebug(lcQtGuiTextureIO, "Invalid ASTC file %s", logName().constData()); + return nullData; + } + + res.setLogName(logName()); + +#if 0 + qDebug() << "ASTC file handler read" << res << res.dataOffset() << res.dataLength(); +#endif + return res; +} + +QT_END_NAMESPACE diff --git a/src/gui/util/qastchandler_p.h b/src/gui/util/qastchandler_p.h new file mode 100644 index 0000000000..398f1833b6 --- /dev/null +++ b/src/gui/util/qastchandler_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 QASTCHANDLER_H +#define QASTCHANDLER_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 "qtexturefilehandler_p.h" + +QT_BEGIN_NAMESPACE + +class QAstcHandler : public QTextureFileHandler +{ +public: + using QTextureFileHandler::QTextureFileHandler; + + static bool canRead(const QByteArray &suffix, const QByteArray &block); + + QTextureFileData read() override; + +private: + quint32 astcGLFormat(quint8 xBlockDim, quint8 yBlockDim) const; +}; + +QT_END_NAMESPACE + +#endif // QASTCHANDLER_H diff --git a/src/gui/util/qtexturefilereader.cpp b/src/gui/util/qtexturefilereader.cpp index 5d4bd600e0..73d6b6811a 100644 --- a/src/gui/util/qtexturefilereader.cpp +++ b/src/gui/util/qtexturefilereader.cpp @@ -37,10 +37,14 @@ ** ****************************************************************************/ +#include #include "qtexturefilereader_p.h" #include "qpkmhandler_p.h" #include "qktxhandler_p.h" +#if QT_CONFIG(texture_format_astc_experimental) +#include "qastchandler_p.h" +#endif #include @@ -80,6 +84,10 @@ bool QTextureFileReader::canRead() m_handler = new QPkmHandler(m_device, logName); } else if (QKtxHandler::canRead(suffix, headerBlock)) { m_handler = new QKtxHandler(m_device, logName); +#if QT_CONFIG(texture_format_astc_experimental) + } else if (QAstcHandler::canRead(suffix, headerBlock)) { + m_handler = new QAstcHandler(m_device, logName); +#endif } // else if OtherHandler::canRead() ...etc. } @@ -89,7 +97,7 @@ bool QTextureFileReader::canRead() QList QTextureFileReader::supportedFileFormats() { // Hardcoded for now - return {QByteArrayLiteral("pkm"), QByteArrayLiteral("ktx")}; + return {QByteArrayLiteral("pkm"), QByteArrayLiteral("ktx"), QByteArrayLiteral("astc")}; } bool QTextureFileReader::init() diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index 6324642505..b36ee60a97 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -39,3 +39,8 @@ SOURCES += \ util/qtexturefilereader.cpp \ util/qpkmhandler.cpp \ util/qktxhandler.cpp + +qtConfig(texture_format_astc_experimental) { + HEADERS += util/qastchandler_p.h + SOURCES += util/qastchandler.cpp +} -- cgit v1.2.3 From 80e7120feb5ddf9d5f0c9ed12bb8580898b18db8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 1 Aug 2019 15:29:01 +0200 Subject: eglfs/kms: Re-enable drm/gbm format overrides in the config file Follow up to 091a386eaf91ad8932332a8aefc2df793de59f6c Defaulting to querying from the egl config is fine, but dropping support for the "format" key in the output list in the json config file is not ideal. Task-number: QTBUG-76748 Change-Id: I25dc99369d118c300cdef25b464426f6be85453b Reviewed-by: Johan Helsing --- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 12 +++++-- src/platformsupport/kmsconvenience/qkmsdevice_p.h | 1 + .../eglfs_kms/qeglfskmsgbmscreen.cpp | 37 +++++++++++++++------- 3 files changed, 36 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 7e3a870421..fec59cfc7b 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -342,10 +342,14 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } qCDebug(qLcKmsDebug) << "Physical size is" << physSize << "mm" << "for output" << connectorName; - const QByteArray formatStr = userConnectorConfig.value(QStringLiteral("format"), QStringLiteral("xrgb8888")) + const QByteArray formatStr = userConnectorConfig.value(QStringLiteral("format"), QString()) .toByteArray().toLower(); uint32_t drmFormat; - if (formatStr == "xrgb8888") { + bool drmFormatExplicit = true; + if (formatStr.isEmpty()) { + drmFormat = DRM_FORMAT_XRGB8888; + drmFormatExplicit = false; + } else if (formatStr == "xrgb8888") { drmFormat = DRM_FORMAT_XRGB8888; } else if (formatStr == "xbgr8888") { drmFormat = DRM_FORMAT_XBGR8888; @@ -368,7 +372,10 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } else { qWarning("Invalid pixel format \"%s\" for output %s", formatStr.constData(), connectorName.constData()); drmFormat = DRM_FORMAT_XRGB8888; + drmFormatExplicit = false; } + qCDebug(qLcKmsDebug) << "Format is" << hex << drmFormat << dec << "requested_by_user =" << drmFormatExplicit + << "for output" << connectorName; const QString cloneSource = userConnectorConfig.value(QStringLiteral("clones")).toString(); if (!cloneSource.isEmpty()) @@ -411,6 +418,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, output.forced_plane_id = 0; output.forced_plane_set = false; output.drm_format = drmFormat; + output.drm_format_requested_by_user = drmFormatExplicit; output.clone_source = cloneSource; output.size = framebufferSize; diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index 403972fbb8..14da6bb947 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -201,6 +201,7 @@ struct QKmsOutput uint32_t forced_plane_id = 0; bool forced_plane_set = false; uint32_t drm_format = DRM_FORMAT_XRGB8888; + bool drm_format_requested_by_user = false; QString clone_source; QVector available_planes; struct QKmsPlane *eglfs_plane = nullptr; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 24f82e7843..3a2951efbd 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -155,20 +155,33 @@ gbm_surface *QEglFSKmsGbmScreen::createSurface(EGLConfig eglConfig) qCDebug(qLcEglfsKmsDebug, "Creating gbm_surface for screen %s", qPrintable(name())); const auto gbmDevice = static_cast(device())->gbmDevice(); - EGLint native_format = -1; - EGLBoolean success = eglGetConfigAttrib(display(), eglConfig, EGL_NATIVE_VISUAL_ID, &native_format); - qCDebug(qLcEglfsKmsDebug) << "Got native format" << hex << native_format << dec << "from eglGetConfigAttrib() with return code" << bool(success); - - if (success) - m_gbm_surface = gbm_surface_create(gbmDevice, - rawGeometry().width(), - rawGeometry().height(), - native_format, - GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + // If there was no format override given in the config file, + // query the native (here, gbm) format from the EGL config. + const bool queryFromEgl = !m_output.drm_format_requested_by_user; + if (queryFromEgl) { + EGLint native_format = -1; + EGLBoolean success = eglGetConfigAttrib(display(), eglConfig, EGL_NATIVE_VISUAL_ID, &native_format); + qCDebug(qLcEglfsKmsDebug) << "Got native format" << hex << native_format << dec + << "from eglGetConfigAttrib() with return code" << bool(success); + + if (success) { + m_gbm_surface = gbm_surface_create(gbmDevice, + rawGeometry().width(), + rawGeometry().height(), + native_format, + GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + if (m_gbm_surface) + m_output.drm_format = gbmFormatToDrmFormat(native_format); + } + } - if (!m_gbm_surface) { // fallback for older drivers + // Fallback for older drivers, and when "format" is explicitly specified + // in the output config. (not guaranteed that the requested format works + // of course, but do what we are told to) + if (!m_gbm_surface) { uint32_t gbmFormat = drmFormatToGbmFormat(m_output.drm_format); - qCDebug(qLcEglfsKmsDebug, "Could not create surface with EGL_NATIVE_VISUAL_ID, falling back to format %x", gbmFormat); + if (queryFromEgl) + qCDebug(qLcEglfsKmsDebug, "Could not create surface with EGL_NATIVE_VISUAL_ID, falling back to format %x", gbmFormat); m_gbm_surface = gbm_surface_create(gbmDevice, rawGeometry().width(), rawGeometry().height(), -- cgit v1.2.3 From 5dc318d5e80b5ec415e981f3e655cc6cdfdab3ba Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 15 Jul 2019 14:50:33 +0200 Subject: Fix typo in description of feature datestring Change-Id: I858512af94b5160a0008789ca972cd57307cc9e2 Reviewed-by: Tasuku Suzuki Reviewed-by: Paul Wicking --- src/corelib/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 5f5a00a64f..de8d26a12b 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -814,7 +814,7 @@ }, "datestring": { "label": "QDate/QTime/QDateTime", - "purpose": "Provides convertion between dates and strings.", + "purpose": "Provides conversion between dates and strings.", "section": "Data structures", "condition": "features.textdate", "output": [ "publicFeature", "feature" ] -- cgit v1.2.3 From ec940f898b42f16bb0727f807b72488fad6d6d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 14 Aug 2019 14:20:03 +0200 Subject: SSL: ALPN: Don't include empty, too long or truncated names As is said in RFC7301 in section 3.1 [1]: Protocols are named by IANA-registered, opaque, non-empty byte strings [...]. Empty strings MUST NOT be included and byte strings MUST NOT be truncated. [1]: https://tools.ietf.org/html/rfc7301#section-3.1 Change-Id: I2c41fa99984a53cc58803e5a264d06edac964cc6 Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslcontext_openssl.cpp | 44 ++++++++++++++++++--------------- src/network/ssl/qsslsocket_mac.cpp | 7 ++++++ 2 files changed, 31 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index 35cca9f01a..675d5f8e62 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -157,32 +157,36 @@ SSL* QSslContext::createSsl() for (int a = 0; a < protocols.count(); ++a) { if (protocols.at(a).size() > 255) { qCWarning(lcSsl) << "TLS NPN extension" << protocols.at(a) - << "is too long and will be truncated to 255 characters."; - protocols[a] = protocols.at(a).left(255); + << "is too long and will be ignored."; + continue; + } else if (protocols.at(a).isEmpty()) { + continue; } m_supportedNPNVersions.append(protocols.at(a).size()).append(protocols.at(a)); } - m_npnContext.data = reinterpret_cast(m_supportedNPNVersions.data()); - m_npnContext.len = m_supportedNPNVersions.count(); - m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone; + if (m_supportedNPNVersions.size()) { + m_npnContext.data = reinterpret_cast(m_supportedNPNVersions.data()); + m_npnContext.len = m_supportedNPNVersions.count(); + m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone; #if OPENSSL_VERSION_NUMBER >= 0x10002000L - if (QSslSocket::sslLibraryVersionNumber() >= 0x10002000L) { - // Callback's type has a parameter 'const unsigned char ** out' - // since it was introduced in 1.0.2. Internally, OpenSSL's own code - // (tests/examples) cast it to unsigned char * (since it's 'out'). - // We just re-use our NPN callback and cast here: - typedef int (*alpn_callback_t) (SSL *, const unsigned char **, unsigned char *, - const unsigned char *, unsigned int, void *); - // With ALPN callback is for a server side only, for a client m_npnContext.status - // will stay in NextProtocolNegotiationNone. - q_SSL_CTX_set_alpn_select_cb(ctx, alpn_callback_t(next_proto_cb), &m_npnContext); - // Client: - q_SSL_set_alpn_protos(ssl, m_npnContext.data, m_npnContext.len); - } + if (QSslSocket::sslLibraryVersionNumber() >= 0x10002000L) { + // Callback's type has a parameter 'const unsigned char ** out' + // since it was introduced in 1.0.2. Internally, OpenSSL's own code + // (tests/examples) cast it to unsigned char * (since it's 'out'). + // We just re-use our NPN callback and cast here: + typedef int (*alpn_callback_t) (SSL *, const unsigned char **, unsigned char *, + const unsigned char *, unsigned int, void *); + // With ALPN callback is for a server side only, for a client m_npnContext.status + // will stay in NextProtocolNegotiationNone. + q_SSL_CTX_set_alpn_select_cb(ctx, alpn_callback_t(next_proto_cb), &m_npnContext); + // Client: + q_SSL_set_alpn_protos(ssl, m_npnContext.data, m_npnContext.len); + } #endif // OPENSSL_VERSION_NUMBER >= 0x10002000L ... - // And in case our peer does not support ALPN, but supports NPN: - q_SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &m_npnContext); + // And in case our peer does not support ALPN, but supports NPN: + q_SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &m_npnContext); + } } #endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ... diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 7c5f4310f8..e6b71b293e 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -928,6 +928,13 @@ bool QSslSocketBackendPrivate::initSslContext() QCFType cfNames(CFArrayCreateMutable(nullptr, 0, &kCFTypeArrayCallBacks)); if (cfNames) { for (const QByteArray &name : protocolNames) { + if (name.size() > 255) { + qCWarning(lcSsl) << "TLS ALPN extension" << name + << "is too long and will be ignored."; + continue; + } else if (name.isEmpty()) { + continue; + } QCFString cfName(QString::fromLatin1(name).toCFString()); CFArrayAppendValue(cfNames, cfName); } -- cgit v1.2.3 From 88d1909871ce1a3016ff61edd8bc2062a79f35fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Wed, 14 Aug 2019 15:40:26 +0200 Subject: Fix macOS build with -no-feature-accessibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id16b102feb7b57efcf1a36385a009774cb023f41 Reviewed-by: Jörg Bornemann --- src/plugins/platforms/cocoa/cocoa.pro | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 02e00039ae..f0dd013922 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -21,8 +21,6 @@ SOURCES += main.mm \ qcocoamenuloader.mm \ qcocoahelpers.mm \ qmultitouch_mac.mm \ - qcocoaaccessibilityelement.mm \ - qcocoaaccessibility.mm \ qcocoacursor.mm \ qcocoaclipboard.mm \ qcocoadrag.mm \ @@ -57,8 +55,6 @@ HEADERS += qcocoaintegration.h \ qcocoamenuloader.h \ qcocoahelpers.h \ qmultitouch_mac_p.h \ - qcocoaaccessibilityelement.h \ - qcocoaaccessibility.h \ qcocoacursor.h \ qcocoaclipboard.h \ qcocoadrag.h \ @@ -83,13 +79,21 @@ qtConfig(vulkan) { HEADERS += qcocoavulkaninstance.h } +qtConfig(accessibility) { + QT += accessibility_support-private + SOURCES += qcocoaaccessibilityelement.mm \ + qcocoaaccessibility.mm + HEADERS += qcocoaaccessibilityelement.h \ + qcocoaaccessibility.h +} + RESOURCES += qcocoaresources.qrc LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups QT += \ core-private gui-private \ - accessibility_support-private clipboard_support-private theme_support-private \ + clipboard_support-private theme_support-private \ fontdatabase_support-private graphics_support-private qtConfig(vulkan): QT += vulkan_support-private -- cgit v1.2.3 From 6d3a4546934827955f0eb2b07a9928f82790ba37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 13 Aug 2019 15:17:40 +0200 Subject: DBus: fix deadlock when destroying QDBusServer Observed infrequently in the QDBus tests, it would deadlock when destroying QDBusServer at the same time as qDBusNewConnection was being executed as they were locking the same locks, but in opposite order. QDBusServer locks d->lock, then QDBusConnectionManager::instance()->mutex. While qDBusNewConnection locks QDBusConnectionManager::instance()->mutex, then serverConnection->lock (and serverConnection here is QDBusServer's d-pointer). QOrderedMutexLocker cannot be used in this situation because it operates on QMutex*, which d->lock (QReadWriteLock) is not. Change the code to lock QDBusConnectionManager's mutex before d->lock and then unlock the QMutexLocker where it would previously destruct. If QDBusConnectionManager has already been destroyed then we pass a nullptr to the QMutexLocker which is fine and will not do anything. Fixes: QTBUG-74635 Change-Id: I7f02d7759da67377996ef042c81b0969ccb8aadb Reviewed-by: Marc Mutz Reviewed-by: Edward Welbourne --- src/dbus/qdbusserver.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index a2dfb86164..3ac5c794e1 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -109,12 +109,16 @@ QDBusServer::QDBusServer(QObject *parent) */ QDBusServer::~QDBusServer() { - QWriteLocker locker(&d->lock); + QMutex *managerMutex = nullptr; + if (QDBusConnectionManager::instance()) + managerMutex = &QDBusConnectionManager::instance()->mutex; + QMutexLocker locker(managerMutex); + QWriteLocker writeLocker(&d->lock); if (QDBusConnectionManager::instance()) { - QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); for (const QString &name : qAsConst(d->serverConnectionNames)) QDBusConnectionManager::instance()->removeConnection(name); d->serverConnectionNames.clear(); + locker.unlock(); } d->serverObject = nullptr; d->ref.store(0); -- cgit v1.2.3 From 257bd49c1f47ba5fca6930082fdcf108f9d24e3f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 14 Aug 2019 19:45:17 +0200 Subject: Guard with a mutex in QOpenGLProgramBinaryCache where needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While there is likely no example of it in Qt itself, applications can use QOpenGLShaderProgram instances on different threads. These instances have nothing to do with each other but they do share a global cache object. This becomes problematic without proper synchronization. Change-Id: I80faf73f34af7e67349eee916bb3f216e22c07fd Fixes: QTBUG-77469 Reviewed-by: Christian Strømme --- src/gui/opengl/qopenglprogrambinarycache.cpp | 2 ++ src/gui/opengl/qopenglprogrambinarycache_p.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp index af48cdacc7..40237b9935 100644 --- a/src/gui/opengl/qopenglprogrambinarycache.cpp +++ b/src/gui/opengl/qopenglprogrambinarycache.cpp @@ -263,6 +263,7 @@ public: bool QOpenGLProgramBinaryCache::load(const QByteArray &cacheKey, uint programId) { + QMutexLocker lock(&m_mutex); if (m_memCache.contains(cacheKey)) { const MemCacheEntry *e = m_memCache[cacheKey]; return setProgramBinary(programId, e->format, e->blob.constData(), e->blob.size()); @@ -401,6 +402,7 @@ void QOpenGLProgramBinaryCache::save(const QByteArray &cacheKey, uint programId) GLint outSize = 0; #if defined(QT_OPENGL_ES_2) if (context->isOpenGLES() && context->format().majorVersion() < 3) { + QMutexLocker lock(&m_mutex); initializeProgramBinaryOES(context); getProgramBinaryOES(programId, blobSize, &outSize, &blobFormat, p); } else diff --git a/src/gui/opengl/qopenglprogrambinarycache_p.h b/src/gui/opengl/qopenglprogrambinarycache_p.h index 9fade08e66..e181a6ab81 100644 --- a/src/gui/opengl/qopenglprogrambinarycache_p.h +++ b/src/gui/opengl/qopenglprogrambinarycache_p.h @@ -54,6 +54,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -99,6 +100,7 @@ private: void initializeProgramBinaryOES(QOpenGLContext *context); bool m_programBinaryOESInitialized = false; #endif + QMutex m_mutex; }; QT_END_NAMESPACE -- cgit v1.2.3 From 70e7445dbeba9bd24de963e7e431c4698b6b4569 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 30 Jul 2019 10:27:41 +0200 Subject: Simplify QBezier::addPolygon() implementation Makes the code a little cleaner, avoiding an issue caused by UB and/or optimization bug in msvc2019. Fixes: QTBUG-77119 Fixes: QTBUG-77230 Change-Id: I9bc8f427a90e6fe32b3c26301bbb703a3c4ad846 Reviewed-by: Friedemann Kleint Reviewed-by: Ville Voutilainen --- src/gui/painting/qbezier.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index 8cda4b4072..65e6063fe4 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -122,10 +122,10 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold int levels[10]; beziers[0] = *this; levels[0] = 9; - QBezier *b = beziers; - int *lvl = levels; + int top = 0; - while (b >= beziers) { + while (top >= 0) { + QBezier *b = &beziers[top]; // check if we can pop the top bezier curve from the stack qreal y4y1 = b->y4 - b->y1; qreal x4x1 = b->x4 - b->x1; @@ -139,17 +139,15 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); l = 1.; } - if (d < bezier_flattening_threshold*l || *lvl == 0) { + if (d < bezier_flattening_threshold * l || levels[top] == 0) { // good enough, we pop it off and add the endpoint polygon->append(QPointF(b->x4, b->y4)); - --b; - --lvl; + --top; } else { // split, second half of the polygon goes lower into the stack b->split(b+1, b); - lvl[1] = --lvl[0]; - ++b; - ++lvl; + levels[top + 1] = --levels[top]; + ++top; } } } @@ -160,10 +158,10 @@ void QBezier::addToPolygon(QDataBuffer &polygon, qreal bezier_flattenin int levels[10]; beziers[0] = *this; levels[0] = 9; - QBezier *b = beziers; - int *lvl = levels; + int top = 0; - while (b >= beziers) { + while (top >= 0) { + QBezier *b = &beziers[top]; // check if we can pop the top bezier curve from the stack qreal y4y1 = b->y4 - b->y1; qreal x4x1 = b->x4 - b->x1; @@ -177,17 +175,15 @@ void QBezier::addToPolygon(QDataBuffer &polygon, qreal bezier_flattenin qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); l = 1.; } - if (d < bezier_flattening_threshold*l || *lvl == 0) { + if (d < bezier_flattening_threshold * l || levels[top] == 0) { // good enough, we pop it off and add the endpoint polygon.add(QPointF(b->x4, b->y4)); - --b; - --lvl; + --top; } else { // split, second half of the polygon goes lower into the stack b->split(b+1, b); - lvl[1] = --lvl[0]; - ++b; - ++lvl; + levels[top + 1] = --levels[top]; + ++top; } } } -- cgit v1.2.3