renderer: swizzle on shm screencopy (#14167)

in ds format (XBGR8888) the swizzle was pretty much being ignored. It
would cause screenshots taken within DS, or apps which use screencopy
like hyprpicker, wayfreeze, and still, to come out with the red and blue
channels flipped.
This commit is contained in:
fazzi 2026-04-26 19:20:18 +01:00 committed by GitHub
parent 2652e2aeab
commit d669ea7db2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -127,21 +127,17 @@ bool CGLFramebuffer::readPixels(CHLBufferReference buffer, uint32_t offsetX, uin
uint32_t packStride = minStride(PFORMAT, m_size.x);
int glFormat = PFORMAT->glFormat;
if (glFormat == GL_RGBA)
glFormat = GL_BGRA_EXT;
if (glFormat != GL_BGRA_EXT && glFormat != GL_RGB) {
if (PFORMAT->swizzle.has_value()) {
if (PFORMAT->swizzle == SWIZZLE_RGBA)
glFormat = GL_RGBA;
else if (PFORMAT->swizzle == SWIZZLE_BGRA)
glFormat = GL_BGRA_EXT;
else {
LOGM(Log::ERR, "Copied frame via shm might be broken or color flipped");
glFormat = GL_RGBA;
}
if (PFORMAT->swizzle.has_value()) {
if (PFORMAT->swizzle == SWIZZLE_RGBA)
glFormat = GL_RGBA;
else if (PFORMAT->swizzle == SWIZZLE_BGRA)
glFormat = GL_BGRA_EXT;
else {
LOGM(Log::ERR, "Copied frame via shm might be broken or color flipped");
glFormat = GL_RGBA;
}
}
} else if (glFormat == GL_RGBA)
glFormat = GL_BGRA_EXT;
// This could be optimized by using a pixel buffer object to make this async,
// but really clients should just use a dma buffer anyways.