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 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 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