From 6bbc6c12565a8838270116d84044fa3c5d68c09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= Date: Tue, 1 Apr 2025 12:00:14 +0200 Subject: [PATCH] gl-renderer: Fix SHM RGB888 and BGR888 endianness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 24 bpp RGB and BGR SHM formats are meant to be stored little endian, not big endian. Fixes a regression in commit 815ccaff. Signed-off-by: Loïc Molinari --- clients/simple-shm.c | 4 ++-- libweston/pixel-formats.c | 4 ++-- tests/shm-buffer-test.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clients/simple-shm.c b/clients/simple-shm.c index a7cde8ef4..b1eff3c38 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -612,11 +612,11 @@ paint_format(void *image, const struct format *format, int width, int height) color = GET_COLOR(i); for (j = 0; j < width; j++) { img8[(i * width + j) * 3 + 0] = - (color >> 16) & 0xff; + (color >> 0) & 0xff; img8[(i * width + j) * 3 + 1] = (color >> 8) & 0xff; img8[(i * width + j) * 3 + 2] = - (color >> 0) & 0xff; + (color >> 16) & 0xff; } } break; diff --git a/libweston/pixel-formats.c b/libweston/pixel-formats.c index 4ff43e282..fc45e2672 100644 --- a/libweston/pixel-formats.c +++ b/libweston/pixel-formats.c @@ -363,7 +363,7 @@ static const struct pixel_format_info pixel_format_table[] = { COLOR_MODEL(RGB), BITS_RGBA_FIXED(8, 8, 8, 0), .bpp = 24, - GL_FORMAT_INFO(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, RGB1), + GL_FORMAT_INFO(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, BGR1), GL_FORMAT(GL_RGB), GL_TYPE(GL_UNSIGNED_BYTE), }, @@ -372,7 +372,7 @@ static const struct pixel_format_info pixel_format_table[] = { COLOR_MODEL(RGB), BITS_RGBA_FIXED(8, 8, 8, 0), .bpp = 24, - GL_FORMAT_INFO(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, BGR1), + GL_FORMAT_INFO(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, RGB1), GL_FORMAT(GL_RGB), GL_TYPE(GL_UNSIGNED_BYTE), }, diff --git a/tests/shm-buffer-test.c b/tests/shm-buffer-test.c index 2ccd00746..669a6f66f 100644 --- a/tests/shm-buffer-test.c +++ b/tests/shm-buffer-test.c @@ -352,13 +352,13 @@ rgb888_create_buffer(struct client *client, uint8_t b = src_row[x]; if (drm_format == DRM_FORMAT_RGB888) { - dst_row[x * 3 + 2] = b; - dst_row[x * 3 + 1] = g; - dst_row[x * 3 + 0] = r; - } else { dst_row[x * 3 + 2] = r; dst_row[x * 3 + 1] = g; dst_row[x * 3 + 0] = b; + } else { + dst_row[x * 3 + 2] = b; + dst_row[x * 3 + 1] = g; + dst_row[x * 3 + 0] = r; } } }