Do automatic r-b swap in QVulkanWindow's grab for BGRA8
While it would also be acceptable to leave this conversion to the user, the returned image's format (that it's QImage::Format_RGBA8888) is not documented. That needs to be corrected in any case. Then, we may just as well add and document that for the most commonly used swapchain color buffer format the r-b swap is performed automatically. Pick-to: 6.5 6.2 Fixes: QTBUG-118244 Change-Id: I7ec8324ec3a0f5c1f2a7a592501d5ff59e3e8cc5 Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io> Reviewed-by: Christian Strømme <christian.stromme@qt.io> (cherry picked from commit 7a3261c196e5e7d5b13ff2746faeedb979944d22) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
2e0b58607e
commit
8a4fd01bf3
@ -1927,7 +1927,7 @@ void QVulkanWindowPrivate::beginFrame()
|
||||
}
|
||||
|
||||
if (frameGrabbing)
|
||||
frameGrabTargetImage = QImage(swapChainImageSize, QImage::Format_RGBA8888);
|
||||
frameGrabTargetImage = QImage(swapChainImageSize, QImage::Format_RGBA8888); // the format is as documented
|
||||
|
||||
if (renderer) {
|
||||
framePending = true;
|
||||
@ -2714,6 +2714,12 @@ bool QVulkanWindow::supportsGrab() const
|
||||
incomplete image, that has the correct size but not the content yet. The
|
||||
content will be delivered via the frameGrabbed() signal in the latter case.
|
||||
|
||||
The returned QImage always has a format of QImage::Format_RGBA8888. If the
|
||||
colorFormat() is \c VK_FORMAT_B8G8R8A8_UNORM, the red and blue channels are
|
||||
swapped automatically since this format is commonly used as the default
|
||||
choice for swapchain color buffers. With any other color buffer format,
|
||||
there is no conversion performed by this function.
|
||||
|
||||
\note This function should not be called when a frame is in progress
|
||||
(that is, frameReady() has not yet been called back by the application).
|
||||
|
||||
@ -2742,6 +2748,9 @@ QImage QVulkanWindow::grab()
|
||||
d->frameGrabbing = true;
|
||||
d->beginFrame();
|
||||
|
||||
if (d->colorFormat == VK_FORMAT_B8G8R8A8_UNORM)
|
||||
d->frameGrabTargetImage = d->frameGrabTargetImage.rgbSwapped();
|
||||
|
||||
return d->frameGrabTargetImage;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user