-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Milestone
Description
As seen in #8317, to do format-sensitive colour conversion, you have to memcpy the right number of bytes into the low-order bits of a Uint32 (which do not necessarily start at byte 0!), and then pass that to SDL_GetRGBA() or SDL_GetRGB() to decode it into its colour channels. This seems unnecessarily tricky to get right.
One possibility to make this easier (and make implementing #8319 easier, if we want it) would be to change their signature from the current:
void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *, Uint8 *, Uint8 *, Uint8 *);
void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *, Uint8 *, Uint8 *, Uint8 *, Uint8 *);
to be something more like
void SDL_GetRGB(const void *pixel, const SDL_PixelFormat *, Uint8 *, Uint8 *, Uint8 *);
void SDL_GetRGBA(const void *pixel, const SDL_PixelFormat *, Uint8 *, Uint8 *, Uint8 *, Uint8 *);
and do the "memcpy the right number of bytes into the low-order bits of a Uint32" step internally.
This might be troublesome for src/render/software/SDL_drawline.c
, though.