Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-sdl2/graphics.h File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
graphics.h File Reference
`#include <SDL2/SDL2_rotozoom.h>`
`#include "graphics_g.h"`
`#include "canvas.h"`
`#include "gui_main.h"`

Go to the source code of this file.

## Data Structures

struct | sdl2_data
struct | gui_layer

## Macros

#define | RECT_LIMIT 80
#define | USE_DUFFS_LOOP
#define | DUFFS_LOOP8(pixel_copy_increment, width)
#define | DUFFS_LOOP4(pixel_copy_increment, width)
#define | DUFFS_LOOP_DOUBLE2(pixel_copy_increment, double_pixel_copy_increment, width)
#define | DUFFS_LOOP_QUATRO2(pixel_copy_increment, double_pixel_copy_increment, quatro_pixel_copy_increment, width)
#define | DUFFS_LOOP(pixel_copy_increment, width) DUFFS_LOOP8(pixel_copy_increment, width)
#define | DEFAULT_ZOOM 1.0
#define | adj_surf(surf) copy_surface(surf)
#define | map_rgba(format, color) SDL_MapRGBA(format, (color).r, (color).g, (color).b, (color).a)
#define | crop_rect_from_screen(rect) crop_rect_from_surface(main_data.screen, &rect)
#define | FREESURFACE(ptr)
#define | lock_surf(surf)
#define | unlock_surf(surf)
#define | lock_screen() lock_surf(main_data.screen)
#define | unlock_screen() unlock_surf(main_data.screen)
#define | putpixel(surf, x, y, pixel)
#define | ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB)
#define | ALPHA_BLEND128(sR, sG, sB, dR, dG, dB)

## Functions

struct gui_layer * | gui_layer_new (int x, int y, SDL_Surface *surface)
void | gui_layer_destroy (struct gui_layer **gui_layer)
struct gui_layer * | get_gui_layer (SDL_Surface *surface)
struct gui_layer * | add_gui_layer (int width, int height)
void | remove_gui_layer (struct gui_layer *gui_layer)
void | screen_rect_to_layer_rect (struct gui_layer *gui_layer, SDL_Rect *dest_rect)
void | layer_rect_to_screen_rect (struct gui_layer *gui_layer, SDL_Rect *dest_rect)
int | alphablit (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
int | screen_blit (SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect, unsigned char alpha_mod)
SDL_Surface * | load_surf (const char *fname)
SDL_Surface * | create_surf_with_format (SDL_PixelFormat *pf, int width, int height, Uint32 flags)
SDL_Surface * | create_surf (int width, int height, Uint32 flags)
SDL_Surface * | convert_surf (SDL_Surface *surf_in)
SDL_Surface * | create_filled_surface (Uint16 w, Uint16 h, Uint32 flags, SDL_Color *pcolor)
SDL_Surface * | crop_rect_from_surface (SDL_Surface *psource, SDL_Rect *prect)
SDL_Surface * | mask_surface (SDL_Surface *src, SDL_Surface *mask, int mask_offset_x, int mask_offset_y)
SDL_Surface * | copy_surface (SDL_Surface *src)
int | blit_entire_src (SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Uint32 | getpixel (SDL_Surface *surf, Sint16 x, Sint16 y)
Uint32 | get_first_pixel (SDL_Surface *surf)
void | create_frame (SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom, SDL_Color *pcolor)
void | create_line (SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
void | init_sdl (int f)
void | quit_sdl (void)
bool | set_video_mode (unsigned width, unsigned height, unsigned flags)
bool | create_surfaces (int width, int height)
void | update_main_screen (void)
int | main_window_width (void)
int | main_window_height (void)
bool | correct_rect_region (SDL_Rect *prect)
bool | is_in_rect_area (int x, int y, SDL_Rect rect)
int | fill_rect_alpha (SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
int | clear_surface (SDL_Surface *surf, SDL_Rect *dstrect)
SDL_Surface * | resize_surface (const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
SDL_Surface * | resize_surface_box (const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth, bool scale_up, bool absolute_dimensions)
SDL_Surface * | crop_visible_part_from_surface (SDL_Surface *psrc)
SDL_Rect | get_smaller_surface_rect (SDL_Surface *psrc)

## Variables

struct sdl2_data | main_data

## Macro Definition Documentation

## ◆ adj_surf

#define adj_surf | ( |  | surf | ) | copy_surface(surf)

Definition at line 200 of file graphics.h.

## ◆ ALPHA_BLEND

#define ALPHA_BLEND | ( |  | sR,
|  |  | sG,
|  |  | sB,
|  |  | A,
|  |  | dR,
|  |  | dG,
|  |  | dB
| ) |  |

Value:
do { \
dR = (((sR-dR)*(A))>>8)+dR; \
dG = (((sG-dG)*(A))>>8)+dG; \
dB = (((sB-dB)*(A))>>8)+dB; \
} while (FALSE)
FALSE
#define FALSE
Definition support.h:47

Definition at line 393 of file graphics.h.

## ◆ ALPHA_BLEND128

#define ALPHA_BLEND128 | ( |  | sR,
|  |  | sG,
|  |  | sB,
|  |  | dR,
|  |  | dG,
|  |  | dB
| ) |  |

Value:
do { \
Uint32 __Src = (sR << 16 | sG << 8 | sB); \
Uint32 __Dst = (dR << 16 | dG << 8 | dB); \
__Dst = ((((__Src & 0x00fefefe) + (__Dst & 0x00fefefe)) >> 1) \
+ (__Src & __Dst & 0x00010101)) | 0xFF000000; \
dR = (__Dst >> 16) & 0xFF; \
dG = (__Dst >> 8 ) & 0xFF; \
dB = (__Dst ) & 0xFF; \
} while (FALSE)

Definition at line 400 of file graphics.h.

## ◆ crop_rect_from_screen

#define crop_rect_from_screen | ( |  | rect | ) | crop_rect_from_surface(main_data.screen, &rect)

Definition at line 318 of file graphics.h.

## ◆ DEFAULT_ZOOM

#define DEFAULT_ZOOM 1.0

Definition at line 198 of file graphics.h.

## ◆ DUFFS_LOOP

#define DUFFS_LOOP | ( |  | pixel_copy_increment,
|  |  | width
| ) |  | DUFFS_LOOP8(pixel_copy_increment, width)

Definition at line 140 of file graphics.h.

## ◆ DUFFS_LOOP4

#define DUFFS_LOOP4 | ( |  | pixel_copy_increment,
|  |  | width
| ) |  |

Value:
{ int n = (width + 3) / 4; \
switch (width & 3) { \
case 0: do { pixel_copy_increment; \
fc__fallthrough; \
case 3: pixel_copy_increment; \
fc__fallthrough; \
case 2: pixel_copy_increment; \
fc__fallthrough; \
case 1: pixel_copy_increment; \
} while ( --n > 0 ); \
} \
}
n
#define n
Definition astring.c:77
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
fc__fallthrough
#define fc__fallthrough
Definition support.h:109

Definition at line 83 of file graphics.h.

## ◆ DUFFS_LOOP8

#define DUFFS_LOOP8 | ( |  | pixel_copy_increment,
|  |  | width
| ) |  |

Value:
{ int n = (width + 7) / 8; \
switch (width & 7) { \
case 0: do { pixel_copy_increment; \
fc__fallthrough; \
case 7: pixel_copy_increment; \
fc__fallthrough; \
case 6: pixel_copy_increment; \
fc__fallthrough; \
case 5: pixel_copy_increment; \
fc__fallthrough; \
case 4: pixel_copy_increment; \
fc__fallthrough; \
case 3: pixel_copy_increment; \
fc__fallthrough; \
case 2: pixel_copy_increment; \
fc__fallthrough; \
case 1: pixel_copy_increment; \
} while ( --n > 0 ); \
} \
}

Definition at line 60 of file graphics.h.

## ◆ DUFFS_LOOP_DOUBLE2

#define DUFFS_LOOP_DOUBLE2 | ( |  | pixel_copy_increment,
|  |  | double_pixel_copy_increment,
|  |  | width
| ) |  |

Value:
{ int n, w = width; \
if ( w & 1 ) { \
pixel_copy_increment; \
w--; \
} \
if ( w > 0 ) { \
n = ( w + 2 ) / 4; \
switch ( w & 2 ) { \
case 0: do { double_pixel_copy_increment; \
fc__fallthrough; \
case 2: double_pixel_copy_increment; \
} while ( --n > 0 ); \
} \
} \
}

Definition at line 98 of file graphics.h.

## ◆ DUFFS_LOOP_QUATRO2

#define DUFFS_LOOP_QUATRO2 | ( |  | pixel_copy_increment,
|  |  | double_pixel_copy_increment,
|  |  | quatro_pixel_copy_increment,
|  |  | width
| ) |  |

Value:
{ int n, w = width; \
if (w & 1) { \
pixel_copy_increment; \
w--; \
} \
if (w & 2) { \
double_pixel_copy_increment; \
w -= 2; \
} \
if ( w > 0 ) { \
n = ( w + 7 ) / 8; \
switch ( w & 4 ) { \
case 0: do { quatro_pixel_copy_increment; \
case 4: quatro_pixel_copy_increment; \
} while ( --n > 0 ); \
} \
} \
}

Definition at line 117 of file graphics.h.

## ◆ FREESURFACE

#define FREESURFACE | ( |  | ptr | ) |

Value:
do { \
if (ptr) { \
SDL_FreeSurface(ptr); \
ptr = NULL; \
} \
} while (FALSE)

Definition at line 322 of file graphics.h.

## ◆ lock_screen

#define lock_screen | ( |  | ) | lock_surf(main_data.screen)

Definition at line 354 of file graphics.h.

## ◆ lock_surf

#define lock_surf | ( |  | surf | ) |

Value:
do { \
if (SDL_MUSTLOCK(surf)) { \
SDL_LockSurface(surf); \
} \
} while (FALSE)

Definition at line 333 of file graphics.h.

## ◆ map_rgba

#define map_rgba | ( |  | format,
|  |  | color
| ) |  | SDL_MapRGBA(format, (color).r, (color).g, (color).b, (color).a)

Definition at line 315 of file graphics.h.

## ◆ putpixel

#define putpixel | ( |  | surf,
|  |  | x,
|  |  | y,
|  |  | pixel
| ) |  |

Value:
do { \
Uint8 *buf_ptr = ((Uint8 *)surf->pixels + (y * surf->pitch)); \
switch (surf->format->BytesPerPixel) { \
case 1: \
buf_ptr += x; \
*(Uint8 *)buf_ptr = pixel; \
break; \
case 2: \
buf_ptr += x << 1; \
*((Uint16 *)buf_ptr) = pixel; \
break; \
case 3: \
buf_ptr += (x << 1) + x; \
if (is_bigendian()) { \
buf_ptr[0] = (pixel >> 16) & 0xff; \
buf_ptr[1] = (pixel >> 8) & 0xff; \
buf_ptr[2] = pixel & 0xff; \
} else { \
buf_ptr[0] = pixel & 0xff; \
buf_ptr[1] = (pixel >> 8) & 0xff; \
buf_ptr[2] = (pixel >> 16) & 0xff; \
} \
break; \
case 4: \
buf_ptr += x << 2; \
*((Uint32 *)buf_ptr) = pixel; \
break; \
} \
} while (FALSE)
is_bigendian
static bool is_bigendian(void)
Definition support.h:201

Definition at line 361 of file graphics.h.

## ◆ RECT_LIMIT

#define RECT_LIMIT 80

Definition at line 45 of file graphics.h.

## ◆ unlock_screen

#define unlock_screen | ( |  | ) | unlock_surf(main_data.screen)

Definition at line 359 of file graphics.h.

## ◆ unlock_surf

#define unlock_surf | ( |  | surf | ) |

Value:
do { \
if (SDL_MUSTLOCK(surf)) { \
SDL_UnlockSurface(surf); \
} \
} while (FALSE)

Definition at line 344 of file graphics.h.

## ◆ USE_DUFFS_LOOP

#define USE_DUFFS_LOOP

Definition at line 54 of file graphics.h.

## Function Documentation

## ◆ add_gui_layer()

struct gui_layer * add_gui_layer | ( | int | width,
|  | int | height
| ) |  |

Buffer allocation function. This function is call by "create_window(...)" function and allocate buffer layer for this function.

Pointer for this buffer is put in buffer array on last position that flush functions will draw this layer last.

Definition at line 112 of file graphics.c.

Referenced by combo_new(), create_edit(), create_surfaces(), and create_window_skeleton().

## ◆ alphablit()

int alphablit | ( | SDL_Surface * | src,
|  | SDL_Rect * | srcrect,
|  | SDL_Surface * | dst,
|  | SDL_Rect * | dstrect,
|  | unsigned char | alpha_mod
| ) |  |

Execute alphablit.

Definition at line 199 of file graphics.c.

Referenced by blit_entire_src(), canvas_copy(), canvas_put_sprite(), canvas_put_sprite_fogged(), canvas_put_sprite_full(), combo_redraw(), create_bcgnd_surf(), create_frame(), create_horizontal_surface(), create_icon_theme_surf(), create_line(), create_select_tech_icon(), create_unit_surface(), create_utf8_multi_surf(), create_vertical_surface(), crop_rect_from_surface(), draw_frame(), draw_icon_from_theme(), draw_intro_gfx(), economy_report_dialog_popup(), flush_mapcanvas(), get_progress_icon(), nation_button_callback(), popup_city_cma_dialog(), popup_diplomacy_dialog(), popup_goto_airlift_dialog(), popup_hurry_production_dialog(), popup_impr_info(), popup_minimap_window(), popup_notify_dialog(), popup_players_dialog(), popup_races_dialog(), popup_sell_impr_callback(), popup_unit_disband_dlg(), popup_unit_info(), popup_unit_upgrade_dlg(), popup_unitinfo_window(), popup_upgrade_unit_callback(), popup_war_dialog(), popup_worklist_editor(), real_activeunits_report_dialog_update(), real_city_dialog_popup(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), real_science_report_dialog_update(), redraw_army_city_dialog(), redraw_checkbox(), redraw_city_dialog(), redraw_edit(), redraw_edit_chain(), redraw_happiness_city_dialog(), redraw_ibutton(), redraw_icon(), redraw_icon2(), redraw_iconlabel(), redraw_info_city_dialog(), redraw_misc_city_dialog(), redraw_supported_units_city_dialog(), redraw_tech_info_dlg(), redraw_themelabel2(), redraw_unit_info_label(), redraw_widget_info_label(), redraw_window(), refresh_overview(), refresh_widget_background(), remove_clause_widget_from_list(), resize_surface_box(), save_cma_callback(), screen_blit(), toggle_map_window_callback(), toggle_unit_info_window_callback(), update_acceptance_icons(), update_city_cma_dialog(), update_intel_dialog(), and write_utf8().

## ◆ blit_entire_src()

int blit_entire_src | ( | SDL_Surface * | psrc,
|  | SDL_Surface * | pdest,
|  | Sint16 | dest_x,
|  | Sint16 | dest_y
| ) |  |

Blit entire src [SOURCE] surface to destination [DEST] surface on position : [dest_x],[dest_y] using it's actual alpha and color key settings.

Definition at line 417 of file graphics.c.

Referenced by canvas_put_text(), popup_minimap_window(), popup_unitinfo_window(), redraw_horiz(), redraw_vert(), setup_auxiliary_tech_icons(), update_info_label(), and widget_core_undraw().

## ◆ clear_surface()

int clear_surface | ( | SDL_Surface * | surf,
|  | SDL_Rect * | dstrect
| ) |  |

Fill surface with (0, 0, 0, 0), so the next blitting operation can set the per pixel alpha

Definition at line 400 of file graphics.c.

Referenced by create_bcgnd_surf(), create_surfaces(), optiondlg_callback(), popdown_all_game_dialogs(), redraw_ibutton(), redraw_window(), refresh_widget_background(), toggle_map_window_callback(), toggle_unit_info_window_callback(), and widget_core_undraw().

## ◆ convert_surf()

SDL_Surface * convert_surf | ( | SDL_Surface * | surf_in | ) |

Convert surface to the main window format.

Definition at line 359 of file graphics.c.

Referenced by load_gfxfile().

## ◆ copy_surface()

SDL_Surface * copy_surface | ( | SDL_Surface * | src | ) |

Return copy of the surface

Definition at line 1308 of file graphics.c.

Referenced by mask_surface(), popup_impr_info(), popup_unit_info(), and setup_auxiliary_tech_icons().

## ◆ correct_rect_region()

bool correct_rect_region | ( | SDL_Rect * | prect | ) |

Make rectangle region sane. Return TRUE if result is sane.

Definition at line 888 of file graphics.c.

Referenced by dirty_sdl_rect(), flush_rect(), and redraw_widget_info_label().

## ◆ create_filled_surface()

SDL_Surface * create_filled_surface | ( | Uint16 | w,
|  | Uint16 | h,
|  | Uint32 | flags,
|  | SDL_Color * | pcolor
| ) |  |

Create an surface with screen format and fill with color. If pcolor == NULL surface is filled with transparent white A = 128

Definition at line 368 of file graphics.c.

Referenced by redraw_widget_info_label().

## ◆ create_frame()

void create_frame | ( | SDL_Surface * | dest,
|  | Sint16 | left,
|  | Sint16 | top,
|  | Sint16 | width,
|  | Sint16 | height,
|  | SDL_Color * | pcolor
| ) |  |

Create colored frame

Definition at line 1347 of file graphics.c.

Referenced by create_icon_theme_surf(), create_select_tech_icon(), draw_selection_rectangle(), economy_report_dialog_popup(), option_dialog_worklist(), popup_city_cma_dialog(), popup_conn_list_dialog(), popup_connection_dialog(), popup_impr_info(), popup_races_dialog(), popup_unit_info(), popup_worklist_editor(), real_activeunits_report_dialog_update(), real_info_city_report_dialog_update(), real_science_report_dialog_update(), redraw_city_dialog(), redraw_icon2(), redraw_impr_info_dlg(), redraw_tech_info_dlg(), redraw_tech_tree_dlg(), redraw_unit_info_dlg(), redraw_widget_info_label(), setup_auxiliary_tech_icons(), tilespec_setup_city_icons(), and update_city_cma_dialog().

## ◆ create_line()

void create_line | ( | SDL_Surface * | dest,
|  | Sint16 | x0,
|  | Sint16 | y0,
|  | Sint16 | x1,
|  | Sint16 | y1,
|  | SDL_Color * | pcolor
| ) |  |

Create single colored line

Definition at line 1378 of file graphics.c.

Referenced by canvas_put_line(), popup_races_dialog(), real_players_dialog_update(), real_science_report_dialog_update(), redraw_edit_chain(), redraw_happiness_city_dialog(), redraw_tech_tree_dlg(), redraw_window(), show_main_page(), tilespec_setup_city_icons(), and update_info_label().

## ◆ create_surf()

SDL_Surface * create_surf | ( | int | width,
|  | int | height,
|  | Uint32 | flags
| ) |  |

Create surface with the same format as main window

Definition at line 351 of file graphics.c.

Referenced by add_gui_layer(), canvas_create(), convert_iconlabel_to_themeiconlabel2(), create_bcgnd_surf(), create_filled_surface(), create_horizontal_surface(), create_icon_theme_surf(), create_select_tech_icon(), create_surfaces(), create_themelabel2(), create_unit_surface(), create_utf8_multi_surf(), create_utf8_surf(), create_vertical_surface(), economy_report_dialog_popup(), load_cursors(), option_dialog_worklist(), popup_advanced_terrain_dialog(), popup_impr_info(), popup_minimap_window(), popup_races_dialog(), popup_sabotage_dialog(), popup_unit_info(), popup_unitinfo_window(), popup_worklist_editor(), redraw_unit_info_label(), resize_surface_box(), resize_window(), setup_auxiliary_tech_icons(), and tilespec_setup_city_icons().

## ◆ create_surf_with_format()

SDL_Surface * create_surf_with_format | ( | SDL_PixelFormat * | pf,
|  | int | width,
|  | int | height,
|  | Uint32 | flags
| ) |  |

Create an surface with format MUST NOT BE USED IF NO SDLSCREEN IS SET

Definition at line 328 of file graphics.c.

Referenced by create_surf(), create_utf8_multi_surf(), and crop_rect_from_surface().

## ◆ create_surfaces()

bool create_surfaces | ( | int | width,
|  | int | height
| ) |  |

Create new main window surfaces.

Definition at line 556 of file graphics.c.

Referenced by fullscreen_callback(), and set_video_mode().

## ◆ crop_rect_from_surface()

SDL_Surface * crop_rect_from_surface | ( | SDL_Surface * | psource,
|  | SDL_Rect * | prect
| ) |  |

Create new surface (prect->w x prect->h size) and copy prect area of psource. if prect == NULL then create copy of entire psource.

Definition at line 236 of file graphics.c.

Referenced by create_icon_from_theme(), crop_sprite(), crop_visible_part_from_surface(), draw_horiz(), draw_vert(), economy_report_dialog_popup(), popup_races_dialog(), popup_worklist_editor(), refresh_widget_background(), and tilespec_setup_city_icons().

## ◆ crop_visible_part_from_surface()

SDL_Surface * crop_visible_part_from_surface | ( | SDL_Surface * | psrc | ) |

Create new surface that is just visible part of source surface.

Definition at line 1226 of file graphics.c.

Referenced by popup_find_dialog(), and update_goto_dialog().

## ◆ fill_rect_alpha()

int fill_rect_alpha | ( | SDL_Surface * | surf,
|  | SDL_Rect * | prect,
|  | SDL_Color * | pcolor
| ) |  |

Fill rectangle with color with alpha channel.

Definition at line 865 of file graphics.c.

Referenced by convert_iconlabel_to_themeiconlabel2(), create_icon_theme_surf(), create_themelabel2(), economy_report_dialog_popup(), popup_city_cma_dialog(), popup_conn_list_dialog(), popup_connection_dialog(), popup_goto_airlift_dialog(), popup_races_dialog(), popup_worklist_editor(), real_activeunits_report_dialog_update(), real_info_city_report_dialog_update(), real_science_report_dialog_update(), redraw_city_dialog(), redraw_impr_info_dlg(), redraw_label(), redraw_tech_info_dlg(), redraw_tech_tree_dlg(), redraw_unit_info_dlg(), redraw_window(), show_main_page(), update_city_cma_dialog(), and update_diplomacy_dialog().

## ◆ get_first_pixel()

Uint32 get_first_pixel | ( | SDL_Surface * | surf | ) |

Get first pixel Return the pixel value at (0, 0) NOTE: The surface must be locked before calling this!

Definition at line 468 of file graphics.c.

## ◆ get_gui_layer()

struct gui_layer * get_gui_layer | ( | SDL_Surface * | surface | ) |

Get surface gui_layer.

Definition at line 90 of file graphics.c.

Referenced by move_group_to_front_of_gui_list(), and window_set_position().

## ◆ get_smaller_surface_rect()

SDL_Rect get_smaller_surface_rect | ( | SDL_Surface * | surf | ) |

Get visible rectangle from surface.

Definition at line 936 of file graphics.c.

Referenced by create_icon_theme_surf(), create_unit_surface(), and crop_visible_part_from_surface().

## ◆ getpixel()

Uint32 getpixel | ( | SDL_Surface * | surf,
|  | Sint16 | x,
|  | Sint16 | y
| ) |  |

Get pixel Return the pixel value at (x, y) NOTE: The surface must be locked before calling this!

Definition at line 430 of file graphics.c.

Referenced by convert_iconlabel_to_themeiconlabel2(), create_themelabel2(), and SurfaceToCursor().

## ◆ gui_layer_destroy()

void gui_layer_destroy | ( | struct gui_layer ** | gui_layer | ) |

Free resources associated with gui_layer.

Definition at line 81 of file graphics.c.

Referenced by quit_sdl(), and remove_gui_layer().

## ◆ gui_layer_new()

struct gui_layer * gui_layer_new | ( | int | x,
|  | int | y,
|  | SDL_Surface * | surface
| ) |  |

Allocate new gui_layer.

Definition at line 66 of file graphics.c.

Referenced by add_gui_layer(), and create_themelabel2().

## ◆ init_sdl()

void init_sdl | ( | int | flags | ) |

Initialize sdl with Flags

Definition at line 506 of file graphics.c.

Referenced by ui_init().

## ◆ is_in_rect_area()

bool is_in_rect_area | ( | int | x,
|  | int | y,
|  | SDL_Rect | rect
| ) |  |

Return whether coordinates are in rectangle.

Definition at line 925 of file graphics.c.

Referenced by check_scroll_area(), city_dlg_callback(), and find_next_widget_at_pos().

## ◆ layer_rect_to_screen_rect()

void layer_rect_to_screen_rect | ( | struct gui_layer * | gui_layer,
|  | SDL_Rect * | dest_rect
| ) |  |

Translate dest_rect from gui_layer's to global screen coordinates.

Definition at line 185 of file graphics.c.

Referenced by refresh_production_label(), and refresh_worklist_count_label().

## ◆ load_surf()

SDL_Surface * load_surf | ( | const char * | fname | ) |

Load a surface from file putting it in software mem.

Definition at line 307 of file graphics.c.

Referenced by theme_get_background().

## ◆ main_window_height()

int main_window_height | ( | void |  | ) |

Return height of the main window

Definition at line 693 of file graphics.c.

Referenced by arrange_widgets(), combo_popup(), correct_rect_region(), draw_intro_gfx(), economy_report_dialog_popup(), flush_dirty(), main_finger_down_handler(), main_finger_up_handler(), nation_button_callback(), notify_goto_dialog_update(), overview_size_changed(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_city_cma_dialog(), popup_conn_list_dialog(), popup_connection_dialog(), popup_diplomacy_dialog(), popup_diplomatic_objects(), popup_find_dialog(), popup_goto_airlift_dialog(), popup_government_dialog(), popup_hurry_production_dialog(), popup_impr_info(), popup_input_line(), popup_join_game_dialog(), popup_load_game_dialog(), popup_new_user_passwd_dialog(), popup_newcity_dialog(), popup_notify_dialog(), popup_players_dialog(), popup_players_nations_dialog(), popup_races_dialog(), popup_spaceship_dialog(), popup_tech_info(), popup_unit_info(), popup_user_passwd_dialog(), popup_war_dialog(), popup_worklist_editor(), put_window_near_map_tile(), real_activeunits_report_dialog_update(), real_city_dialog_popup(), real_info_city_report_dialog_update(), real_resize_window_callback(), science_report_dialog_popup(), sell_imprvm_dlg_callback(), set_new_minimap_window_pos(), set_new_unitinfo_window_pos(), show_main_page(), spy_steal_popup_shared(), update_diplomacy_dialog(), and update_intel_dialog().

## ◆ main_window_width()

int main_window_width | ( | void |  | ) |

Return width of the main window

Definition at line 685 of file graphics.c.

Referenced by arrange_widgets(), combo_popup(), correct_rect_region(), draw_intro_gfx(), economy_report_dialog_popup(), flush_dirty(), main_finger_down_handler(), main_finger_up_handler(), meswin_dialog_popup(), nation_button_callback(), notify_goto_dialog_update(), overview_size_changed(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_city_cma_dialog(), popup_conn_list_dialog(), popup_connection_dialog(), popup_diplomacy_dialog(), popup_find_dialog(), popup_goto_airlift_dialog(), popup_government_dialog(), popup_hurry_production_dialog(), popup_impr_info(), popup_input_line(), popup_join_game_dialog(), popup_load_game_dialog(), popup_new_user_passwd_dialog(), popup_newcity_dialog(), popup_notify_dialog(), popup_players_dialog(), popup_players_nations_dialog(), popup_races_dialog(), popup_spaceship_dialog(), popup_tech_info(), popup_unit_info(), popup_user_passwd_dialog(), popup_war_dialog(), popup_worklist_editor(), put_window_near_map_tile(), real_activeunits_report_dialog_update(), real_city_dialog_popup(), real_info_city_report_dialog_update(), real_resize_window_callback(), redraw_widget_info_label(), science_report_dialog_popup(), sell_imprvm_dlg_callback(), set_new_order_widget_start_pos(), set_new_unitinfo_window_pos(), show_main_page(), spy_steal_popup_shared(), toggle_unit_info_window_callback(), update_diplomacy_dialog(), update_info_label(), and update_intel_dialog().

## ◆ mask_surface()

SDL_Surface * mask_surface | ( | SDL_Surface * | src,
|  | SDL_Surface * | mask,
|  | int | mask_offset_x,
|  | int | mask_offset_y
| ) |  |

Reduce the alpha of the final surface proportional to the alpha of the mask. Thus if the mask has 50% alpha the final image will be reduced by 50% alpha.

mask_offset_x, mask_offset_y is the offset of the mask relative to the origin of the source image. The pixel at (mask_offset_x, mask_offset_y) in the mask image will be used to clip pixel (0, 0) in the source image which is pixel (-x, -y) in the new image.

Definition at line 262 of file graphics.c.

Referenced by crop_sprite().

## ◆ quit_sdl()

void quit_sdl | ( | void |  | ) |

Free screen buffers

Definition at line 622 of file graphics.c.

Referenced by ui_main().

## ◆ remove_gui_layer()

void remove_gui_layer | ( | struct gui_layer * | gui_layer | ) |

Free buffer layer ( call by popdown_window_group_dialog(...) func ) Func. Free buffer layer and clear buffer array entry.

Definition at line 148 of file graphics.c.

Referenced by notify_goto_dialog_destroy(), and popdown_window_group_dialog().

## ◆ resize_surface()

SDL_Surface * resize_surface | ( | const SDL_Surface * | psrc,
|  | Uint16 | new_width,
|  | Uint16 | new_height,
|  | int | smooth
| ) |  |

Scale surface.

Definition at line 1236 of file graphics.c.

Referenced by create_bcgnd_surf(), create_select_tech_icon(), draw_frame(), draw_intro_gfx(), popup_goto_airlift_dialog(), popup_minimap_window(), popup_unitinfo_window(), real_city_report_dialog_update_city(), resize_window(), science_report_dialog_popup(), toggle_map_window_callback(), and toggle_unit_info_window_callback().

## ◆ resize_surface_box()

SDL_Surface * resize_surface_box | ( | const SDL_Surface * | psrc,
|  | Uint16 | new_width,
|  | Uint16 | new_height,
|  | int | smooth,
|  | bool | scale_up,
|  | bool | absolute_dimensions
| ) |  |

Resize a surface to fit into a box with the dimensions 'new_width' and a 'new_height'. If 'scale_up' is FALSE, a surface that already fits into the box will not be scaled up to the boundaries of the box. If 'absolute_dimensions' is TRUE, the function returns a surface with the dimensions of the box and the scaled/original surface centered in it.

Definition at line 1256 of file graphics.c.

Referenced by create_tech_info(), create_unit_surface(), popup_goto_airlift_dialog(), popup_impr_info(), popup_unit_info(), real_info_city_report_dialog_update(), rebuild_imprm_list(), and redraw_unit_info_label().

## ◆ screen_blit()

int screen_blit | ( | SDL_Surface * | src,
|  | SDL_Rect * | srcrect,
|  | SDL_Rect * | dstrect,
|  | unsigned char | alpha_mod
| ) |  |

Execute alphablit to the main surface

Definition at line 223 of file graphics.c.

Referenced by draw_mouse_cursor(), flush_dirty(), flush_rect(), and redraw_widget_info_label().

## ◆ screen_rect_to_layer_rect()

void screen_rect_to_layer_rect | ( | struct gui_layer * | gui_layer,
|  | SDL_Rect * | dest_rect
| ) |  |

Translate dest_rect from global screen to gui_layer's coordinates.

Definition at line 173 of file graphics.c.

Referenced by flush_dirty(), and flush_rect().

## ◆ set_video_mode()

bool set_video_mode | ( | unsigned | width,
|  | unsigned | height,
|  | unsigned | flags_in
| ) |  |

Switch to given video mode.

Definition at line 636 of file graphics.c.

Referenced by ui_main().

## ◆ update_main_screen()

void update_main_screen | ( | void |  | ) |

Render from main surface with screen renderer.

Definition at line 669 of file graphics.c.

Referenced by draw_mouse_cursor(), flush_dirty(), gui_event_loop(), and redraw_widget_info_label().

## Variable Documentation

## ◆ main_data

struct sdl2_data main_data

extern

Definition at line 57 of file graphics.c.

Referenced by accept_treaty_callback(), act_sel_wait_callback(), activate_and_exit_units_orders_city_dlg_callback(), activate_units_orders_city_dlg_callback(), add_gui_layer(), add_new_worklist_callback(), adv_unit_select_all_callback(), adv_unit_select_callback(), adv_unit_sentry_idle_callback(), advanced_terrain_window_dlg_callback(), apply_callback(), apply_taxrates_callback(), army_city_dlg_callback(), back_callback(), bribe_dlg_window_callback(), buy_prod_city_dlg_callback(), call_meeting_dlg_callback(), cancel_buy_prod_city_dlg_callback(), cancel_connect_dlg_callback(), cancel_disband_unit_callback(), cancel_help_dlg_callback(), cancel_meeting_callback(), cancel_pact_dlg_callback(), cancel_sdip_dlg_callback(), cancel_sell_impr_callback(), cancel_sld_cma_callback(), cancel_units_orders_city_dlg_callback(), cancel_upgrade_unit_callback(), cancel_upgrade_unit_callback(), change_gov_callback(), change_impr_callback(), change_prod_dlg_callback(), change_production_callback(), change_research_callback(), change_research_goal_callback(), change_research_goal_dialog_callback(), change_sex_callback(), change_tech_callback(), change_unit_callback(), check_scroll_area(), cities_action_callback(), cities_callback(), city_dlg_callback(), city_report_windows_callback(), client_options_callback(), cma_callback(), cma_city_dlg_callback(), combo_menu_callback(), combo_menu_item_callback(), connect_callback(), convert_first_passwd_callback(), convert_passwd_callback(), convert_playername_callback(), convert_portnr_callback(), convert_second_passwd_callback(), convert_servername_callback(), create_surfaces(), create_units_order_widgets(), del_cma_callback(), diplomat_bribe_callback(), diplomat_bribe_yes_callback(), diplomat_close_callback(), diplomat_dlg_window_callback(), diplomat_incite_callback(), diplomat_incite_yes_callback(), dirty_all(), dirty_sdl_rect(), disband_unit_window_callback(), disband_units_orders_city_dlg_callback(), disconnect_callback(), disconnect_conn_callback(), draw_intro_gfx(), draw_mouse_cursor(), draw_selection_rectangle(), economy_callback(), economy_dialog_callback(), edit_worklist_callback(), embassy_callback(), end_turn_callback(), exit_advanced_terrain_dlg_callback(), exit_bribe_dlg_callback(), exit_callback(), exit_change_tech_dlg_callback(), exit_city_dlg_callback(), exit_city_report_callback(), exit_cma_dialog_callback(), exit_economy_dialog_callback(), exit_find_city_dlg_callback(), exit_goto_dialog_callback(), exit_help_dlg_callback(), exit_incite_dlg_callback(), exit_intel_dlg_callback(), exit_load_dlg_callback(), exit_meta_server_dlg_callback(), exit_notify_dialog_callback(), exit_pillage_dlg_callback(), exit_players_dlg_callback(), exit_players_nations_dlg_callback(), exit_space_dialog_callback(), exit_spy_tgt_dlg_callback(), exit_terrain_info_dialog_callback(), exit_unit_select_callback(), exit_units_dlg_callback(), factor_horiz_cma_callback(), find_city_callback(), find_city_window_dlg_callback(), flush_all(), flush_dirty(), flush_mapcanvas(), flush_rect(), focus_units_info_callback(), fortify_units_orders_city_dlg_callback(), found_city_callback(), free_surfaces(), fullscreen_callback(), get_gui_layer(), global_worklist_callback(), goto_city_callback(), goto_dialog_window_callback(), goto_here_callback(), government_dlg_callback(), gui_event_loop(), happy_city_dlg_callback(), help_browser_callback(), homecity_units_orders_city_dlg_callback(), horiz_taxrate_callback(), hurry_production_callback(), hurry_production_window_callback(), incite_dlg_window_callback(), info_city_dlg_callback(), init_options_button(), init_sdl(), intel_window_dlg_callback(), join_game_callback(), launch_spaceship_callback(), ld_cma_callback(), leader_name_edit_callback(), load_cma_callback(), load_game_callback(), load_game_callback(), load_selected_game_callback(), main_optiondlg_callback(), maps_callback(), min_horiz_cma_callback(), minimap_window_callback(), misc_panel_city_dlg_callback(), move_government_dlg_callback(), move_group_to_front_of_gui_list(), move_load_game_dlg_callback(), move_msg_window_callback(), move_new_city_dlg_callback(), msg_callback(), nation_button_callback(), nations_dialog_callback(), newcity_cancel_callback(), newcity_name_edit_callback(), newcity_ok_callback(), next_name_callback(), next_prev_city_dlg_callback(), next_set_callback(), notify_dialog_window_callback(), notify_goto_dialog_callback(), notify_goto_dialog_close_callback(), notify_goto_dialog_goto_callback(), ok_buy_prod_city_dlg_callback(), ok_disband_unit_window_callback(), ok_save_cma_callback(), ok_sell_impr_callback(), ok_upgrade_unit_window_callback(), ok_upgrade_unit_window_callback(), ok_worklist_editor_callback(), option_category_callback(), optiondlg_callback(), options_callback(), options_city_dlg_callback(), pact_callback(), paradrop_here_callback(), patrol_here_callback(), pillage_callback(), pillage_window_callback(), player_nation_callback(), players_action_callback(), players_window_dlg_callback(), popdown_all_game_dialogs(), popdown_science_dialog_callback(), popdown_worklist_editor_callback(), popup_buy_production_from_city_report_callback(), popup_change_research_dialog_callback(), popup_change_research_goal_dialog_callback(), popup_citydlg_from_city_report_callback(), popup_cma_from_city_report_callback(), popup_find_dialog(), popup_input_line(), popup_players_nations_dialog(), popup_sell_impr_callback(), popup_unit_disband_dlg(), popup_unit_upgrade_dlg(), popup_upgrade_unit_callback(), popup_worklist_from_city_report_callback(), prev_name_callback(), prev_set_callback(), quit_callback(), quit_sdl(), races_dialog_cancel_callback(), races_dialog_ok_callback(), redraw_widget_info_label(), remove_clause_callback(), remove_gui_layer(), rename_worklist_editor_callback(), research_callback(), resource_map_city_dlg_callback(), revolution_callback(), run_cma_callback(), run_cma_once_callback(), sabotage_impr_callback(), save_client_options_callback(), save_cma_callback(), save_game_callback(), science_dialog_callback(), sdip_window_callback(), select_meta_servers_callback(), select_nation_callback(), sell_impr_window_callback(), sell_imprvm_dlg_callback(), sell_imprvm_dlg_cancel_callback(), sell_imprvm_dlg_ok_callback(), send_passwd_callback(), sentry_units_orders_city_dlg_callback(), server_options_callback(), servers_callback(), set_video_mode(), show_game_page(), show_tech_tree_callback(), simple_action_callback(), space_dialog_window_callback(), spaceship_callback(), spy_incite_callback(), spy_steal_callback(), spy_steal_dlg_window_callback(), start_game_callback(), start_new_game_callback(), std_down_advanced_dlg_callback(), std_up_advanced_dlg_callback(), std_vscroll_advanced_dlg_callback(), stop_cma_callback(), style_callback(), supported_unit_city_dlg_callback(), techs_callback(), terrain_info_callback(), terrain_info_window_dlg_callback(), toggle_block_callback(), toggle_cma_celebrating_callback(), toggle_draw_alliance_status_callback(), toggle_draw_ceasefire_status_callback(), toggle_draw_neutral_status_callback(), toggle_draw_peace_status_callback(), toggle_draw_war_status_callback(), toggle_full_tree_mode_in_help_dlg_callback(), toggle_goto_nations_cities_dialog_callback(), toggle_map_window_callback(), toggle_msg_window_callback(), toggle_unit_info_window_callback(), unit_help_callback(), unit_info_window_callback(), unit_order_callback(), unit_select_callback(), unit_select_window_callback(), units_action_callback(), units_dialog_callback(), units_orders_city_dlg_callback(), update_info_label(), update_main_screen(), upgrade_callback(), upgrade_unit_window_callback(), upgrade_unit_window_callback(), upgrade_units_orders_city_dlg_callback(), vision_callback(), widget_pressed_action(), withdraw_vision_dlg_callback(), work_lists_callback(), worklist_editor_item_callback(), worklist_editor_targets_callback(), and zoom_to_city_callback().