1
0
mirror of https://invent.kde.org/network/krfb synced 2024-07-03 00:18:36 +00:00

pipewire: Support BGRA

It's not supported by QImage, so we need to do it ourselves by swapping
the B and the R.
This commit is contained in:
Aleix Pol 2020-11-26 18:43:42 +01:00 committed by Aleix Pol Gonzalez
parent e1e359fa7b
commit f041cdf095

View File

@ -777,7 +777,14 @@ void PWFrameBuffer::Private::handleFrame(pw_buffer *pwBuffer)
cleanup();
#if PW_CHECK_VERSION(0, 2, 90)
if (videoFormat->format != SPA_VIDEO_FORMAT_RGB) {
if (videoFormat->format == SPA_VIDEO_FORMAT_BGRA || videoFormat->format == SPA_VIDEO_FORMAT_BGRx) {
for (uint y = 0; y < videoFormat->size.height; y++) {
for (uint x = 0; x < videoFormat->size.width; x++) {
uint offset = y * spaBuffer->datas->chunk->stride + x * 4;
std::swap(q->fb[offset], q->fb[offset + 2]);
}
}
} else if (videoFormat->format != SPA_VIDEO_FORMAT_RGB) {
const QImage::Format format = videoFormat->format == SPA_VIDEO_FORMAT_BGR ? QImage::Format_BGR888
: videoFormat->format == SPA_VIDEO_FORMAT_RGBx ? QImage::Format_RGBX8888
: QImage::Format_RGB32;