Project

General

Profile

Feature #26 » 0020-sdl3-Replace-SDL_FillRect-call-with-SDL_FillSurfaceR.patch

S3_2 - Marko Lindqvist, 12/04/2023 11:03 PM

View differences:

client/gui-sdl3/action_dialog.c
area2.y = buf->size.h / 2 - 1;
area2.w = buf->size.w - adj_size(20);
SDL_FillRect(buf->theme , &area2, map_rgba(buf->theme->format,
*get_theme_color(COLOR_THEME_SABOTAGEDLG_SEPARATOR)));
SDL_FillSurfaceRect(buf->theme , &area2, map_rgba(buf->theme->format,
*get_theme_color(COLOR_THEME_SABOTAGEDLG_SEPARATOR)));
}
if (buf == last) {
client/gui-sdl3/canvas.c
}
/**********************************************************************//**
Draw a full sprite onto the canvas. If "fog" is specified draw it with
Draw a full sprite onto the canvas. If "fog" is specified draw it with
fog.
**************************************************************************/
void canvas_put_sprite_fogged(struct canvas *pcanvas,
......
{
SDL_Rect dst = {canvas_x, canvas_y, width, height};
SDL_FillRect(pcanvas->surf, &dst, SDL_MapRGBA(pcanvas->surf->format,
pcolor->color->r,
pcolor->color->g,
pcolor->color->b,
pcolor->color->a));
SDL_FillSurfaceRect(pcanvas->surf, &dst,
SDL_MapRGBA(pcanvas->surf->format,
pcolor->color->r,
pcolor->color->g,
pcolor->color->b,
pcolor->color->a));
}
/**********************************************************************//**
......
GET_SURF(psprite)->w,
GET_SURF(psprite)->h};
SDL_FillRect(pcanvas->surf, &dst, SDL_MapRGBA(pcanvas->surf->format,
pcolor->color->r,
pcolor->color->g,
pcolor->color->b,
pcolor->color->a));
SDL_FillSurfaceRect(pcanvas->surf, &dst,
SDL_MapRGBA(pcanvas->surf->format,
pcolor->color->r,
pcolor->color->g,
pcolor->color->b,
pcolor->color->a));
}
/**********************************************************************//**
......
}
/**********************************************************************//**
Return the size of the given text in the given font. This size should
include the ascent and descent of the text. Either of width or height
Return the size of the given text in the given font. This size should
include the ascent and descent of the text. Either of width or height
may be NULL in which case those values simply shouldn't be filled out.
**************************************************************************/
void get_text_size(int *width, int *height,
......
}
/**********************************************************************//**
Draw the text onto the canvas in the given color and font. The canvas
Draw the text onto the canvas in the given color and font. The canvas
position does not account for the ascent of the text; this function must
take care of this manually. The text will not be NULL but may be empty.
take care of this manually. The text will not be NULL but may be empty.
**************************************************************************/
void canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y,
enum client_font font, struct color *pcolor,
client/gui-sdl3/dialogs.c
area.h += buf->size.h;
/* ----------- */
#if 0 /* FIXME: specific connect buttons */
#if 0 /* FIXME: Specific connect buttons */
if (unit_has_type_flag(focus_unit, UTYF_SETTLERS)) {
create_active_iconlabel(buf, pwindow->dst->surface, pstr, _("Connect here"),
connect_here_callback);
......
widget_add_as_prev(buf, last->prev);
area.h += buf->size.h;
/* separator */
/* Separator */
buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
buf->id = ID_SEPARATOR;
widget_add_as_prev(buf, last->prev->prev);
......
}
#undef ADV_NUM_SEEN
} else { /* n == 1 */
/* one unit - give orders */
/* One unit - give orders */
punit = unit_list_get(ptile->units, 0);
punittype = unit_type_get(punit);
if (punit != focus_unit) {
......
area2.h = adj_size(2);
buf = buf->prev;
while (buf) {
while (buf != NULL) {
if (buf == advanced_terrain_dlg->end_active_widget_list) {
w -= units_h;
}
......
area2.y = buf->size.h / 2 - 1;
area2.w = buf->size.w - adj_size(20);
SDL_FillRect(buf->theme, &area2, map_rgba(buf->theme->format,
*get_theme_color(COLOR_THEME_ADVANCEDTERRAINDLG_TEXT)));
SDL_FillSurfaceRect(buf->theme, &area2,
map_rgba(buf->theme->format,
*get_theme_color(COLOR_THEME_ADVANCEDTERRAINDLG_TEXT)));
}
if (buf == advanced_terrain_dlg->begin_widget_list
......
/* Create Imprv Background Icon */
main_bg = create_surf(adj_size(96*2), adj_size(64), SDL_SWSURFACE);
SDL_FillRect(main_bg, NULL, map_rgba(main_bg->format, bg_color));
SDL_FillSurfaceRect(main_bg, NULL,
map_rgba(main_bg->format, bg_color));
create_frame(main_bg,
0, 0, main_bg->w - 1, main_bg->h - 1,
client/gui-sdl3/graphics.c
pcolor = &color;
}
SDL_FillRect(new_surf, NULL,
SDL_MapRGBA(new_surf->format, pcolor->r, pcolor->g, pcolor->b,
pcolor->a));
SDL_FillSurfaceRect(new_surf, NULL,
SDL_MapRGBA(new_surf->format,
pcolor->r, pcolor->g, pcolor->b,
pcolor->a));
if (pcolor->a != 255) {
SDL_SetSurfaceAlphaMod(new_surf, pcolor->a);
......
**************************************************************************/
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
{
/* SDL_FillRect might change the rectangle, so we create a copy */
/* SDL_FillSurfaceRect() might change the rectangle, so we create a copy */
if (dstrect) {
SDL_Rect _dstrect = *dstrect;
return SDL_FillRect(surf, &_dstrect, SDL_MapRGBA(surf->format, 0, 0, 0, 0));
return SDL_FillSurfaceRect(surf, &_dstrect,
SDL_MapRGBA(surf->format, 0, 0, 0, 0));
} else {
return SDL_FillRect(surf, NULL, SDL_MapRGBA(surf->format, 0, 0, 0, 0));
return SDL_FillSurfaceRect(surf, NULL,
SDL_MapRGBA(surf->format, 0, 0, 0, 0));
}
}
......
return *((Uint32 *)surf->pixels + y * surf->pitch / sizeof(Uint32) + x);
default:
return 0; /* shouldn't happen, but avoids warnings */
return 0; /* Shouldn't happen, but avoids warnings */
}
}
......
}
if (pcolor->a == 255) {
return SDL_FillRect(surf, prect,
SDL_MapRGB(surf->format, pcolor->r, pcolor->g, pcolor->b));
return SDL_FillSurfaceRect(surf, prect,
SDL_MapRGB(surf->format,
pcolor->r, pcolor->g, pcolor->b));
}
if (!pcolor->a) {
client/gui-sdl3/gui_string.c
static struct ttf_font_chain {
struct ttf_font_chain *next;
TTF_Font *font;
Uint16 ptsize; /* size of font */
Uint16 count; /* number of strings alliased with this font */
Uint16 ptsize; /* Size of font */
Uint16 count; /* Number of strings alliased with this font */
} *font_tab = NULL;
static char *font_with_full_path = NULL;
......
switch (pstr->render) {
case 1:
text = create_surf(w, count * tmp[0]->h, SDL_SWSURFACE);
SDL_FillRect(text, NULL, color);
SDL_FillSurfaceRect(text, NULL, color);
SDL_SetColorKey(text, SDL_TRUE, color);
break;
case 2:
text = create_surf_with_format(tmp[0]->format,
w, count * tmp[0]->h);
SDL_FillRect(text, NULL, color);
SDL_FillSurfaceRect(text, NULL, color);
break;
default:
text = create_surf(w, count * tmp[0]->h, SDL_SWSURFACE);
SDL_FillRect(text, NULL, color);
SDL_FillSurfaceRect(text, NULL, color);
break;
}
client/gui-sdl3/gui_tilespec.c
load_city_icon_surface(spr, police, "city.police");
/* ================================================================= */
icons->worklist = create_surf(9,9, SDL_SWSURFACE);
SDL_FillRect(icons->worklist, NULL,
SDL_MapRGB(icons->worklist->format, 255, 255,255));
SDL_FillSurfaceRect(icons->worklist, NULL,
SDL_MapRGB(icons->worklist->format, 255, 255,255));
create_frame(icons->worklist,
0, 0, icons->worklist->w - 1, icons->worklist->h - 1,
......
/* Create icons */
surf = create_surf(adj_size(50), adj_size(50), SDL_SWSURFACE);
SDL_FillRect(surf, NULL, map_rgba(surf->format, bg_color));
SDL_FillSurfaceRect(surf, NULL, map_rgba(surf->format, bg_color));
create_frame(surf,
0 , 0, surf->w - 1, surf->h - 1,
get_theme_color(COLOR_THEME_SCIENCEDLG_FRAME));
client/gui-sdl3/helpdlg.c
/* Background template for entries in scroll list */
background_tmpl = create_surf(adj_size(135), adj_size(40), SDL_SWSURFACE);
SDL_FillRect(background_tmpl, NULL, map_rgba(background_tmpl->format, bg_color));
SDL_FillSurfaceRect(background_tmpl, NULL,
map_rgba(background_tmpl->format, bg_color));
create_frame(background_tmpl,
0, 0, background_tmpl->w - 1, background_tmpl->h - 1,
......
/* Background template for entries in scroll list */
background_tmpl = create_surf(adj_size(135), adj_size(40), SDL_SWSURFACE);
SDL_FillRect(background_tmpl, NULL, map_rgba(background_tmpl->format, bg_color));
SDL_FillSurfaceRect(background_tmpl, NULL,
map_rgba(background_tmpl->format, bg_color));
create_frame(background_tmpl,
0, 0, background_tmpl->w - 1, background_tmpl->h - 1,
client/gui-sdl3/mapctrl.c
h += (units_info_window->size.h - units_info_window->area.h);
}
/* clear area under old map window */
/* Clear area under old map window */
clear_surface(pwidget->dst->surface, &pwidget->size);
widget_mark_dirty(pwidget);
......
area.w = w - BLOCKU_W - (units_info_window->size.w - units_info_window->area.w);
area.h = h - (units_info_window->size.h - units_info_window->area.h);
SDL_FillRect(pwidget->theme, &area, map_rgba(pwidget->theme->format, bg_color));
SDL_FillSurfaceRect(pwidget->theme, &area, map_rgba(pwidget->theme->format, bg_color));
/* economy button */
/* Economy button */
pwidget = tax_button;
FREESURFACE(pwidget->gfx);
pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
+ (BLOCKU_W - pwidget->size.w) / 2;
pwidget->size.y = pwidget->dst->surface->h - h + pwidget->area.y + 2;
/* research button */
/* Research button */
pwidget = pwidget->prev;
FREESURFACE(pwidget->gfx);
pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
......
pwidget->size.y = pwidget->dst->surface->h - h + units_info_window->area.y +
pwidget->size.h + 2;
/* revolution button */
/* Revolution button */
pwidget = pwidget->prev;
FREESURFACE(pwidget->gfx);
pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
......
pwidget->size.y = pwidget->dst->surface->h - h + units_info_window->area.y +
pwidget->size.h * 2 + 2;
/* show/hide unit's window button */
/* Show/hide unit's window button */
pwidget = pwidget->prev;
FREESURFACE(pwidget->gfx);
pwidget->size.x = pwidget->dst->surface->w - w + units_info_window->area.x
client/gui-sdl3/mapview.c
area.w = tmp->w + adj_size(8);
area.h = tmp->h + adj_size(4);
SDL_FillRect(main_data.gui->surface, &area,
map_rgba(main_data.gui->surface->format, bg_color));
SDL_FillSurfaceRect(main_data.gui->surface, &area,
map_rgba(main_data.gui->surface->format, bg_color));
/* Horizontal lines */
create_line(main_data.gui->surface,
client/gui-sdl3/optiondlg.c
background->theme = create_surf(area.w, area.h, SDL_SWSURFACE);
widget_set_area(background, area);
widget_set_position(background, area.x, area.y);
SDL_FillRect(background->theme, NULL,
map_rgba(background->theme->format, bg_color));
SDL_FillSurfaceRect(background->theme, NULL,
map_rgba(background->theme->format, bg_color));
create_frame(background->theme,
0, 0, background->theme->w - 1, background->theme->h - 1,
client/gui-sdl3/repodlgs.c
/* Create Imprv Background Icon */
background = create_surf(adj_size(116), adj_size(116), SDL_SWSURFACE);
SDL_FillRect(background, NULL, map_rgba(background->format, bg_color));
SDL_FillSurfaceRect(background, NULL, map_rgba(background->format, bg_color));
create_frame(background,
0, 0, background->w - 1, background->h - 1,
......
text = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4));
/* create label surface */
/* Create label surface */
surf = create_surf(w, h, SDL_SWSURFACE);
if (tech_id == research_get(client_player())->researching) {
......
color.a = 128;
}
SDL_FillRect(surf, NULL, map_rgba(surf->format, color));
SDL_FillSurfaceRect(surf, NULL, map_rgba(surf->format, color));
create_frame(surf,
0,0, surf->w - 1, surf->h - 1,
......
tmp = get_tech_icon(tech_id);
if (mode == TIM_SMALL_MODE) {
/* draw name tech text */
/* Draw name tech text */
dst.x = adj_size(35) + (surf->w - text->w - adj_size(35)) / 2;
dst.y = (surf->h - text->h) / 2;
alphablit(text, NULL, surf, &dst, 255);
FREESURFACE(text);
/* draw tech icon */
/* Draw tech icon */
text = resize_surface(tmp, adj_size(25), adj_size(25), 1);
dst.x = (adj_size(35) - text->w) / 2;
dst.y = (surf->h - text->h) / 2;
......
} else {
/* draw name tech text */
/* Draw name tech text */
dst.x = (surf->w - text->w) / 2;
dst.y = adj_size(20);
alphablit(text, NULL, surf, &dst, 255);
dst.y += text->h + adj_size(10);
FREESURFACE(text);
/* draw tech icon */
/* Draw tech icon */
dst.x = (surf->w - tmp->w) / 2;
alphablit(tmp, NULL, surf, &dst, 255);
dst.y += tmp->w + adj_size(10);
/* fill array with iprvm. icons */
/* Fill array with iprvm. icons */
w = 0;
improvement_iterate(pimprove) {
requirement_vector_iterate(&pimprove->reqs, preq) {
......
dst.x = (surf->w - surf_array[0]->w) / 2;
}
/* draw iprvm. icons */
/* Draw iprvm. icons */
buf_array = surf_array;
h = 0;
while (w) {
client/gui-sdl3/sprite.c
mypixbuf = SDL_CreateSurface(width, height, SDL_PIXELFORMAT_RGBA8888);
SDL_FillRect(mypixbuf, NULL,
SDL_MapRGBA(mypixbuf->format,
pcolor->color->r,
pcolor->color->g,
pcolor->color->b,
pcolor->color->a));
SDL_FillSurfaceRect(mypixbuf, NULL,
SDL_MapRGBA(mypixbuf->format,
pcolor->color->r,
pcolor->color->g,
pcolor->color->b,
pcolor->color->a));
return ctor_sprite(mypixbuf);
}
client/gui-sdl3/widget_label.c
colorkey = SDL_MapRGBA(ptheme->format, pstr->bgcol.r,
pstr->bgcol.g, pstr->bgcol.b, pstr->bgcol.a);
SDL_FillRect(ptheme, NULL, colorkey);
SDL_FillSurfaceRect(ptheme, NULL, colorkey);
label->size.x = 0;
label->size.y = 0;
......
area.y = label->size.h;
if (flags & WF_RESTORE_BACKGROUND) {
SDL_FillRect(ptheme, &area, map_rgba(ptheme->format, bg_color));
SDL_FillSurfaceRect(ptheme, &area,
map_rgba(ptheme->format, bg_color));
store = pstr->bgcol;
SDL_GetRGBA(getpixel(ptheme, area.x , area.y), ptheme->format,
&pstr->bgcol.r, &pstr->bgcol.g,
......
icon_label->string_utf8->bgcol.g,
icon_label->string_utf8->bgcol.b,
icon_label->string_utf8->bgcol.a);
SDL_FillRect(ptheme, NULL, colorkey);
SDL_FillSurfaceRect(ptheme, NULL, colorkey);
start = icon_label->size;
icon_label->size.x = 0;
......
pdest = icon_label->dst->surface;
icon_label->dst->surface = ptheme;
/* normal */
/* Normal */
redraw_iconlabel(icon_label);
/* selected */
/* Selected */
area.x = 0;
area.y = icon_label->size.h;
if (flags & WF_RESTORE_BACKGROUND) {
SDL_FillRect(ptheme, &area, map_rgba(ptheme->format, bg_color));
SDL_FillSurfaceRect(ptheme, &area,
map_rgba(ptheme->format, bg_color));
store = icon_label->string_utf8->bgcol;
SDL_GetRGBA(getpixel(ptheme, area.x , area.y), ptheme->format,
&icon_label->string_utf8->bgcol.r,
......
y = (label->size.h - text->h) / 2;
/* redraw theme */
/* Redraw theme */
if (label->theme) {
ret = blit_entire_src(label->theme, label->dst->surface, label->size.x, label->size.y);
if (ret) {
client/gui-sdl3/widget_window.c
pcolor = &color;
}
SDL_FillRect(pwindow->theme, NULL, map_rgba(pwindow->theme->format, *pcolor));
SDL_FillSurfaceRect(pwindow->theme, NULL,
map_rgba(pwindow->theme->format, *pcolor));
return TRUE;
}
client/gui-sdl3/wldlg.c
advanced_tech = (pcity == NULL);
/* --------------- */
/* create Target Background Icon */
/* Create Target Background Icon */
main_surf = create_surf(adj_size(116), adj_size(116), SDL_SWSURFACE);
SDL_FillRect(main_surf, NULL, map_rgba(main_surf->format, bg_color));
SDL_FillSurfaceRect(main_surf, NULL, map_rgba(main_surf->format, bg_color));
create_frame(main_surf,
0, 0, main_surf->w - 1, main_surf->h - 1,
......
dst.w = adj_size(130);
dst.h = adj_size(145);
SDL_FillRect(pwindow->theme, &dst,
map_rgba(pwindow->theme->format,
*get_theme_color(COLOR_THEME_BACKGROUND)));
SDL_FillSurfaceRect(pwindow->theme, &dst,
map_rgba(pwindow->theme->format,
*get_theme_color(COLOR_THEME_BACKGROUND)));
create_frame(pwindow->theme,
dst.x, dst.y, dst.w - 1, dst.h - 1,
......
dst.w = adj_size(130);
dst.h = pwindow->size.h - dst.y - adj_size(4);
SDL_FillRect(pwindow->theme, &dst,
map_rgba(pwindow->theme->format,
*get_theme_color(COLOR_THEME_BACKGROUND)));
SDL_FillSurfaceRect(pwindow->theme, &dst,
map_rgba(pwindow->theme->format,
*get_theme_color(COLOR_THEME_BACKGROUND)));
create_frame(pwindow->theme,
dst.x, dst.y, dst.w - 1, dst.h - 1,
......
(main_window_width() - pwindow->size.w) / 2,
(main_window_height() - pwindow->size.h) / 2);
/* name */
/* Name */
buf = pwindow->prev;
buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
buf->size.y = area.y + adj_size(4);
/* size of worklist (without production) */
/* Size of worklist (without production) */
buf = buf->prev;
buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
buf->size.y = buf->next->size.y + buf->next->size.h;
if (pcity) {
/* current build and progress bar */
/* Current build and progress bar */
buf = buf->prev;
buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(5);
......
buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
buf->size.y = buf->next->size.y + buf->next->size.h;
} else {
/* rename worklist */
/* Rename worklist */
buf = buf->prev;
buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
buf->size.y = area.y + 1 + (adj_size(145) - buf->size.h) / 2;
}
/* ok button */
/* Ok button */
buf = buf->prev;
buf->size.x = area.x + (adj_size(65) - buf->size.w) / 2;
buf->size.y = area.y + adj_size(135) - buf->size.h;
/* exit button */
/* Exit button */
buf = buf->prev;
buf->size.x = area.x + adj_size(65) + (adj_size(65) - buf->size.w) / 2;
buf->size.y = area.y + adj_size(135) - buf->size.h;
/* worklist */
/* Worklist */
/* editor->work->scroll->count: including production */
if (len > 0) {
/* FIXME */
......
adj_size(225), FALSE);
}
/* global worklists */
/* Global worklists */
if (editor->global) {
setup_vertical_widgets_position(1,
area.x + adj_size(4),
(2-2/2)