Project

General

Profile

Feature #874 » 0036-sdl3-Update-SDL_GetRGBA-calls.patch

Marko Lindqvist, 09/18/2024 09:03 PM

View differences:

client/gui-sdl3/graphics.h
SDL_Surface *crop_visible_part_from_surface(SDL_Surface *psrc);
void get_smaller_surface_rect(SDL_Surface *surf, SDL_Rect *rect);
#define map_rgba_details(details, color) \
SDL_MapRGBA(details, NULL, (color).r, (color).g, (color).b, (color).a)
#define map_rgba(format, color) \
SDL_MapRGBA(SDL_GetPixelFormatDetails(format), NULL, (color).r, (color).g, (color).b, (color).a)
map_rgba_details(SDL_GetPixelFormatDetails(format), color)
#define crop_rect_from_screen(rect) \
crop_rect_from_surface(main_data.screen, &rect)
client/gui-sdl3/gui_mouse.c
Uint8 *data, *mask, *d, *m, r, g, b, a;
Uint32 color;
SDL_Cursor *cursor;
const SDL_PixelFormatDetails *details = SDL_GetPixelFormatDetails(image->format);
w = (image->w + 7) / 8;
data = (Uint8 *)fc_calloc(1, w * image->h * 2);
......
m = mask + y * w;
for (x = 0; x < image->w; x++) {
color = getpixel(image, x, y);
SDL_GetRGBA(color, image->format, &r, &g, &b, &a);
SDL_GetRGBA(color, details, NULL,
&r, &g, &b, &a);
if (a != 0) {
color = (r + g + b) / 3;
m[x / 8] |= 128 >> (x & 7);
client/gui-sdl3/widget_label.c
SDL_Color store = {0, 0, 0, 0};
SDL_Color bg_color = *get_theme_color(COLOR_THEME_THEMELABEL2_BG);
Uint32 colorkey;
const struct SDL_PixelFormatDetails *details;
if (icon == NULL && pstr == NULL) {
return NULL;
......
ptheme = create_surf(label->size.w, label->size.h * 2);
colorkey = SDL_MapRGBA(SDL_GetPixelFormatDetails(ptheme->format),
NULL, pstr->bgcol.r, pstr->bgcol.g, pstr->bgcol.b,
details = SDL_GetPixelFormatDetails(ptheme->format);
colorkey = SDL_MapRGBA(details, NULL,
pstr->bgcol.r, pstr->bgcol.g, pstr->bgcol.b,
pstr->bgcol.a);
SDL_FillSurfaceRect(ptheme, NULL, colorkey);
......
if (flags & WF_RESTORE_BACKGROUND) {
SDL_FillSurfaceRect(ptheme, &area,
map_rgba(ptheme->format, bg_color));
map_rgba_details(details, bg_color));
store = pstr->bgcol;
SDL_GetRGBA(getpixel(ptheme, area.x , area.y), ptheme->format,
SDL_GetRGBA(getpixel(ptheme, area.x , area.y),
details, NULL,
&pstr->bgcol.r, &pstr->bgcol.g,
&pstr->bgcol.b, &pstr->bgcol.a);
} else {
......
SDL_Surface *pdest;
SDL_Surface *ptheme = create_surf(icon_label->size.w,
icon_label->size.h * 2);
const SDL_PixelformaDetails *details = SDL_GetPixelFormatDetails(ptheme->format);
colorkey = SDL_MapRGBA(SDL_GetPixelFormatDetails(ptheme->format),
NULL,
colorkey = SDL_MapRGBA(details, NULL,
icon_label->string_utf8->bgcol.r,
icon_label->string_utf8->bgcol.g,
icon_label->string_utf8->bgcol.b,
......
if (flags & WF_RESTORE_BACKGROUND) {
SDL_FillSurfaceRect(ptheme, &area,
map_rgba(ptheme->format, bg_color));
map_rgba_details(details, bg_color));
store = icon_label->string_utf8->bgcol;
SDL_GetRGBA(getpixel(ptheme, area.x , area.y), ptheme->format,
SDL_GetRGBA(getpixel(ptheme, area.x , area.y),
details, NULL,
&icon_label->string_utf8->bgcol.r,
&icon_label->string_utf8->bgcol.g,
&icon_label->string_utf8->bgcol.b,
(1-1/2)