From 20ddf45ede720be22fa9305809f3aa7b922cde97 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sat, 2 Nov 2019 22:58:52 +0000 Subject: [PATCH] Added SDL_PIXELFORMAT_BGR444 --- include/SDL_pixels.h | 3 +++ src/test/SDL_test_common.c | 3 +++ src/video/SDL_pixels.c | 7 +++++++ test/testautomation_pixels.c | 4 +++- test/testautomation_surface.c | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/SDL_pixels.h b/include/SDL_pixels.h index 2e2b05c78..753f617ad 100644 --- a/include/SDL_pixels.h +++ b/include/SDL_pixels.h @@ -191,6 +191,9 @@ typedef enum SDL_PIXELFORMAT_RGB444 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_4444, 12, 2), + SDL_PIXELFORMAT_BGR444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_4444, 12, 2), SDL_PIXELFORMAT_RGB555 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_1555, 15, 2), diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index cf46837ce..10058491e 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -577,6 +577,9 @@ SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format) case SDL_PIXELFORMAT_RGB444: SDL_snprintfcat(text, maxlen, "RGB444"); break; + case SDL_PIXELFORMAT_BGR444: + SDL_snprintfcat(text, maxlen, "BGR444"); + break; case SDL_PIXELFORMAT_RGB555: SDL_snprintfcat(text, maxlen, "RGB555"); break; diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 21748772c..9ce363ad6 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -94,6 +94,7 @@ SDL_GetPixelFormatName(Uint32 format) CASE(SDL_PIXELFORMAT_INDEX8) CASE(SDL_PIXELFORMAT_RGB332) CASE(SDL_PIXELFORMAT_RGB444) + CASE(SDL_PIXELFORMAT_BGR444) CASE(SDL_PIXELFORMAT_RGB555) CASE(SDL_PIXELFORMAT_BGR555) CASE(SDL_PIXELFORMAT_ARGB4444) @@ -321,6 +322,12 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Amask == 0x0000) { return SDL_PIXELFORMAT_RGB444; } + if (Rmask == 0x000F && + Gmask == 0x00F0 && + Bmask == 0x0F00 && + Amask == 0x0000) { + return SDL_PIXELFORMAT_BGR444; + } break; case 15: if (Rmask == 0) { diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c index 7b88caaa9..b54be8699 100644 --- a/test/testautomation_pixels.c +++ b/test/testautomation_pixels.c @@ -10,7 +10,7 @@ /* Test case functions */ /* Definition of all RGB formats used to test pixel conversions */ -const int _numRGBPixelFormats = 30; +const int _numRGBPixelFormats = 31; Uint32 _RGBPixelFormats[] = { SDL_PIXELFORMAT_INDEX1LSB, @@ -20,6 +20,7 @@ Uint32 _RGBPixelFormats[] = SDL_PIXELFORMAT_INDEX8, SDL_PIXELFORMAT_RGB332, SDL_PIXELFORMAT_RGB444, + SDL_PIXELFORMAT_BGR444, SDL_PIXELFORMAT_RGB555, SDL_PIXELFORMAT_BGR555, SDL_PIXELFORMAT_ARGB4444, @@ -53,6 +54,7 @@ char* _RGBPixelFormatsVerbose[] = "SDL_PIXELFORMAT_INDEX8", "SDL_PIXELFORMAT_RGB332", "SDL_PIXELFORMAT_RGB444", + "SDL_PIXELFORMAT_BGR444", "SDL_PIXELFORMAT_RGB555", "SDL_PIXELFORMAT_BGR555", "SDL_PIXELFORMAT_ARGB4444", diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index ca41d4a0c..92c078685 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -310,6 +310,7 @@ surface_testCompleteSurfaceConversion(void *arg) SDL_PIXELFORMAT_INDEX8, SDL_PIXELFORMAT_RGB332, SDL_PIXELFORMAT_RGB444, + SDL_PIXELFORMAT_BGR444, SDL_PIXELFORMAT_RGB555, SDL_PIXELFORMAT_BGR555, SDL_PIXELFORMAT_ARGB4444,