Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-sdl2/graphics.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
graphics.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 graphics.c - description
16 -------------------
17 begin : Mon Jul 1 2002
18 copyright : (C) 2000 by Michael Speck
19 : (C) 2002 by Rafał Bursig
20 email : Michael Speck <kulkanie@gmx.net>
21 : Rafał Bursig <bursig@poczta.fm>
22***********************************************************************/
23
24#ifdef HAVE_CONFIG_H
25#include <fc_config.h>
26#endif
27
28/* SDL2 */
29#ifdef SDL2_PLAIN_INCLUDE
30#include <SDL_image.h>
31#include <SDL_syswm.h>
32#include <SDL_ttf.h>
33#else /* SDL2_PLAIN_INCLUDE */
34#include <SDL2/SDL_image.h>
35#include <SDL2/SDL_syswm.h>
36#include <SDL2/SDL_ttf.h>
37#endif /* SDL2_PLAIN_INCLUDE */
38
39/* utility */
40#include "fcintl.h"
41#include "log.h"
42
43/* client */
44#include "tilespec.h"
45
46/* gui-sdl2 */
47#include "colors.h"
48#include "gui_tilespec.h"
49#include "mapview.h"
50#include "themebackgrounds.h"
51#include "themespec.h"
52
53#include "graphics.h"
54
55/* ------------------------------ */
56
57 struct sdl2_data main_data;
58
59 static SDL_Surface *main_surface = NULL;
60
61 static bool render_dirty = TRUE;
62
63/**********************************************************************/
66 struct gui_layer *gui_layer_new(int x, int y, SDL_Surface *surface)
67{
68 struct gui_layer *result;
69
70 result = fc_calloc(1, sizeof(struct gui_layer));
71
72 result->dest_rect = (SDL_Rect){x, y, 0, 0};
73 result->surface = surface;
74
75 return result;
76}
77
78/**********************************************************************/
81 void gui_layer_destroy(struct gui_layer **gui_layer)
82{
83 FREESURFACE((*gui_layer)->surface);
84 FC_FREE(*gui_layer);
85}
86
87/**********************************************************************/
90 struct gui_layer *get_gui_layer(SDL_Surface *surface)
91{
92 int i = 0;
93
94 while ((i < main_data.guis_count) && main_data.guis[i]) {
95 if (main_data.guis[i]->surface == surface) {
96 return main_data.guis[i];
97 }
98 i++;
99 }
100
101 return NULL;
102}
103
104/**********************************************************************/
112 struct gui_layer *add_gui_layer(int width, int height)
113{
114 struct gui_layer *gui_layer = NULL;
115 SDL_Surface *buffer;
116
117 buffer = create_surf(width, height, SDL_SWSURFACE);
118 gui_layer = gui_layer_new(0, 0, buffer);
119
120 /* add to buffers array */
121 if (main_data.guis) {
122 int i;
123
124 /* find NULL element */
125 for (i = 0; i < main_data.guis_count; i++) {
126 if (!main_data.guis[i]) {
127 main_data.guis[i] = gui_layer;
128 return gui_layer;
129 }
130 }
131 main_data.guis_count++;
132 main_data.guis = fc_realloc(main_data.guis,
133 main_data.guis_count * sizeof(struct gui_layer *));
134 main_data.guis[main_data.guis_count - 1] = gui_layer;
135 } else {
136 main_data.guis = fc_calloc(1, sizeof(struct gui_layer *));
137 main_data.guis[0] = gui_layer;
138 main_data.guis_count = 1;
139 }
140
141 return gui_layer;
142}
143
144/**********************************************************************/
148 void remove_gui_layer(struct gui_layer *gui_layer)
149{
150 int i;
151
152 for (i = 0; i < main_data.guis_count - 1; i++) {
153 if (main_data.guis[i] && (main_data.guis[i] == gui_layer)) {
154 gui_layer_destroy(&main_data.guis[i]);
155 main_data.guis[i] = main_data.guis[i + 1];
156 main_data.guis[i + 1] = NULL;
157 } else {
158 if (!main_data.guis[i]) {
159 main_data.guis[i] = main_data.guis[i + 1];
160 main_data.guis[i + 1] = NULL;
161 }
162 }
163 }
164
165 if (main_data.guis[main_data.guis_count - 1]) {
166 gui_layer_destroy(&main_data.guis[main_data.guis_count - 1]);
167 }
168}
169
170/**********************************************************************/
173 void screen_rect_to_layer_rect(struct gui_layer *gui_layer,
174 SDL_Rect *dest_rect)
175{
176 if (gui_layer) {
177 dest_rect->x = dest_rect->x - gui_layer->dest_rect.x;
178 dest_rect->y = dest_rect->y - gui_layer->dest_rect.y;
179 }
180}
181
182/**********************************************************************/
185 void layer_rect_to_screen_rect(struct gui_layer *gui_layer,
186 SDL_Rect *dest_rect)
187{
188 if (gui_layer) {
189 dest_rect->x = dest_rect->x + gui_layer->dest_rect.x;
190 dest_rect->y = dest_rect->y + gui_layer->dest_rect.y;
191 }
192}
193
194/* ============ Freeciv sdl graphics function =========== */
195
196/**********************************************************************/
199 int alphablit(SDL_Surface *src, SDL_Rect *srcrect,
200 SDL_Surface *dst, SDL_Rect *dstrect,
201 unsigned char alpha_mod)
202{
203 int ret;
204
205 if (src == NULL || dst == NULL) {
206 return 1;
207 }
208
209 SDL_SetSurfaceAlphaMod(src, alpha_mod);
210
211 ret = SDL_BlitSurface(src, srcrect, dst, dstrect);
212
213 if (ret) {
214 log_error("SDL_BlitSurface() fails: %s", SDL_GetError());
215 }
216
217 return ret;
218}
219
220/**********************************************************************/
223 int screen_blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect,
224 unsigned char alpha_mod)
225{
226 render_dirty = TRUE;
227
228 return alphablit(src, srcrect, main_surface, dstrect, alpha_mod);
229}
230
231/**********************************************************************/
236 SDL_Surface *crop_rect_from_surface(SDL_Surface *psource,
237 SDL_Rect *prect)
238{
239 SDL_Surface *new_surf = create_surf_with_format(psource->format,
240 prect ? prect->w : psource->w,
241 prect ? prect->h : psource->h,
242 SDL_SWSURFACE);
243
244 if (alphablit(psource, prect, new_surf, NULL, 255) != 0) {
245 FREESURFACE(new_surf);
246
247 return NULL;
248 }
249
250 return new_surf;
251}
252
253/**********************************************************************/
262 SDL_Surface *mask_surface(SDL_Surface *src, SDL_Surface *mask,
263 int mask_offset_x, int mask_offset_y)
264{
265 SDL_Surface *dest = NULL;
266 int row, col;
267 Uint32 *src_pixel = NULL;
268 Uint32 *dest_pixel = NULL;
269 Uint32 *mask_pixel = NULL;
270 unsigned char src_alpha, mask_alpha;
271
272 dest = copy_surface(src);
273
274 lock_surf(src);
275 lock_surf(mask);
276 lock_surf(dest);
277
278 src_pixel = (Uint32 *)src->pixels;
279 dest_pixel = (Uint32 *)dest->pixels;
280
281 for (row = 0; row < src->h; row++) {
282 mask_pixel = (Uint32 *)mask->pixels
283 + mask->w * (row + mask_offset_y)
284 + mask_offset_x;
285
286 for (col = 0; col < src->w; col++) {
287 src_alpha = (*src_pixel & src->format->Amask) >> src->format->Ashift;
288 mask_alpha = (*mask_pixel & mask->format->Amask) >> mask->format->Ashift;
289
290 *dest_pixel = (*src_pixel & ~src->format->Amask)
291 | (((src_alpha * mask_alpha) / 255) << dest->format->Ashift);
292
293 src_pixel++; dest_pixel++; mask_pixel++;
294 }
295 }
296
297 unlock_surf(dest);
298 unlock_surf(mask);
299 unlock_surf(src);
300
301 return dest;
302}
303
304/**********************************************************************/
307 SDL_Surface *load_surf(const char *fname)
308{
309 SDL_Surface *buf;
310
311 if (!fname) {
312 return NULL;
313 }
314
315 if ((buf = IMG_Load(fname)) == NULL) {
316 log_error(_("load_surf: Failed to load graphic file %s!"), fname);
317
318 return NULL;
319 }
320
321 return buf;
322}
323
324/**********************************************************************/
328 SDL_Surface *create_surf_with_format(SDL_PixelFormat *pf,
329 int width, int height,
330 Uint32 flags)
331{
332 SDL_Surface *surf = SDL_CreateRGBSurface(flags, width, height,
333 pf->BitsPerPixel,
334 pf->Rmask,
335 pf->Gmask,
336 pf->Bmask, pf->Amask);
337
338 if (surf == NULL) {
339 log_error(_("Unable to create Sprite (Surface) of size "
340 "%d x %d %d Bits in format %d"),
341 width, height, pf->BitsPerPixel, flags);
342 return NULL;
343 }
344
345 return surf;
346}
347
348/**********************************************************************/
351 SDL_Surface *create_surf(int width, int height, Uint32 flags)
352{
353 return create_surf_with_format(main_surface->format, width, height, flags);
354}
355
356/**********************************************************************/
359 SDL_Surface *convert_surf(SDL_Surface *surf_in)
360{
361 return SDL_ConvertSurface(surf_in, main_surface->format, 0);
362}
363
364/**********************************************************************/
368 SDL_Surface *create_filled_surface(Uint16 w, Uint16 h, Uint32 flags,
369 SDL_Color *pcolor)
370{
371 SDL_Surface *new_surf;
372 SDL_Color color = {255, 255, 255, 128};
373
374 new_surf = create_surf(w, h, flags);
375
376 if (!new_surf) {
377 return NULL;
378 }
379
380 if (!pcolor) {
381 /* pcolor->unused == ALPHA */
382 pcolor = &color;
383 }
384
385 SDL_FillRect(new_surf, NULL,
386 SDL_MapRGBA(new_surf->format, pcolor->r, pcolor->g, pcolor->b,
387 pcolor->a));
388
389 if (pcolor->a != 255) {
390 SDL_SetSurfaceAlphaMod(new_surf, pcolor->a);
391 }
392
393 return new_surf;
394}
395
396/**********************************************************************/
400 int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
401{
402 /* SDL_FillRect might change the rectangle, so we create a copy */
403 if (dstrect) {
404 SDL_Rect _dstrect = *dstrect;
405
406 return SDL_FillRect(surf, &_dstrect, SDL_MapRGBA(surf->format, 0, 0, 0, 0));
407 } else {
408 return SDL_FillRect(surf, NULL, SDL_MapRGBA(surf->format, 0, 0, 0, 0));
409 }
410}
411
412/**********************************************************************/
417 int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest,
418 Sint16 dest_x, Sint16 dest_y)
419{
420 SDL_Rect dest_rect = { dest_x, dest_y, 0, 0 };
421
422 return alphablit(psrc, NULL, pdest, &dest_rect, 255);
423}
424
425/**********************************************************************/
430 Uint32 getpixel(SDL_Surface *surf, Sint16 x, Sint16 y)
431{
432 if (!surf) {
433 return 0x0;
434 }
435
436 switch (surf->format->BytesPerPixel) {
437 case 1:
438 return *(Uint8 *) ((Uint8 *) surf->pixels + y * surf->pitch + x);
439
440 case 2:
441 return *((Uint16 *)surf->pixels + y * surf->pitch / sizeof(Uint16) + x);
442
443 case 3:
444 {
445 /* Here ptr is the address to the pixel we want to retrieve */
446 Uint8 *ptr =
447 (Uint8 *) surf->pixels + y * surf->pitch + x * 3;
448
449 if (is_bigendian()) {
450 return ptr[0] << 16 | ptr[1] << 8 | ptr[2];
451 } else {
452 return ptr[0] | ptr[1] << 8 | ptr[2] << 16;
453 }
454 }
455 case 4:
456 return *((Uint32 *)surf->pixels + y * surf->pitch / sizeof(Uint32) + x);
457
458 default:
459 return 0; /* shouldn't happen, but avoids warnings */
460 }
461}
462
463/**********************************************************************/
468 Uint32 get_first_pixel(SDL_Surface *surf)
469{
470 if (!surf) {
471 return 0;
472 }
473
474 switch (surf->format->BytesPerPixel) {
475 case 1:
476 return *((Uint8 *)surf->pixels);
477
478 case 2:
479 return *((Uint16 *)surf->pixels);
480
481 case 3:
482 {
483 if (is_bigendian()) {
484 return (((Uint8 *)surf->pixels)[0] << 16)
485 | (((Uint8 *)surf->pixels)[1] << 8)
486 | ((Uint8 *)surf->pixels)[2];
487 } else {
488 return ((Uint8 *)surf->pixels)[0]
489 | (((Uint8 *)surf->pixels)[1] << 8)
490 | (((Uint8 *)surf->pixels)[2] << 16);
491 }
492 }
493 case 4:
494 return *((Uint32 *)surf->pixels);
495
496 default:
497 return 0; /* shouldn't happen, but avoids warnings */
498 }
499}
500
501/* ===================================================================== */
502
503/**********************************************************************/
506 void init_sdl(int flags)
507{
508 bool error;
509
510 main_data.screen = NULL;
511 main_data.guis = NULL;
512 main_data.gui = NULL;
513 main_data.map = NULL;
514 main_data.dummy = NULL; /* Can't create yet -- hope we don't need it */
515 main_data.renderer = NULL;
516 main_data.rects_count = 0;
517 main_data.guis_count = 0;
518
519 if (SDL_WasInit(SDL_INIT_AUDIO)) {
520 error = (SDL_InitSubSystem(flags) < 0);
521 } else {
522 error = (SDL_Init(flags) < 0);
523 }
524 if (error) {
525 log_fatal(_("Unable to initialize SDL2 library: %s"), SDL_GetError());
526 exit(EXIT_FAILURE);
527 }
528
529 atexit(SDL_Quit);
530
531 /* Initialize the TTF library */
532 if (TTF_Init() < 0) {
533 log_fatal(_("Unable to initialize SDL2_ttf library: %s"), SDL_GetError());
534 exit(EXIT_FAILURE);
535 }
536
537 atexit(TTF_Quit);
538}
539
540/**********************************************************************/
543 static void free_surfaces(void)
544{
545 if (main_data.renderer != NULL) {
546 SDL_DestroyRenderer(main_data.renderer);
547 main_data.renderer = NULL;
548
549 FREESURFACE(main_surface);
550 }
551}
552
553/**********************************************************************/
556 bool create_surfaces(int width, int height)
557{
558 unsigned flags;
559
560 free_surfaces();
561
562 if (is_bigendian()) {
563 main_surface = SDL_CreateRGBSurface(0, width, height, 32,
564 0x0000FF00, 0x00FF0000,
565 0xFF000000, 0x000000FF);
566 main_data.map = SDL_CreateRGBSurface(0, width, height, 32,
567 0x0000FF00, 0x00FF0000,
568 0xFF000000, 0x000000FF);
569 } else {
570 main_surface = SDL_CreateRGBSurface(0, width, height, 32,
571 0x00FF0000, 0x0000FF00,
572 0x000000FF, 0xFF000000);
573 main_data.map = SDL_CreateRGBSurface(0, width, height, 32,
574 0x00FF0000, 0x0000FF00,
575 0x000000FF, 0xFF000000);
576 }
577
578 if (main_surface == NULL || main_data.map == NULL) {
579 log_fatal(_("Failed to create RGB surface: %s"), SDL_GetError());
580 return FALSE;
581 }
582
583 if (GUI_SDL_OPTION(swrenderer)
584 || (sdl2_client_flags & CF_SWRENDERER)) {
585 flags = SDL_RENDERER_SOFTWARE;
586 } else {
587 flags = 0;
588 }
589
590 main_data.renderer = SDL_CreateRenderer(main_data.screen, -1, flags);
591
592 if (main_data.renderer == NULL) {
593 log_fatal(_("Failed to create renderer: %s"), SDL_GetError());
594 return FALSE;
595 }
596
597 main_data.maintext = SDL_CreateTexture(main_data.renderer,
598 SDL_PIXELFORMAT_ARGB8888,
599 SDL_TEXTUREACCESS_STREAMING,
600 width, height);
601
602 if (main_data.maintext == NULL) {
603 log_fatal(_("Failed to create texture: %s"), SDL_GetError());
604 return FALSE;
605 }
606
607 if (main_data.gui) {
608 FREESURFACE(main_data.gui->surface);
609 main_data.gui->surface = create_surf(width, height, SDL_SWSURFACE);
610 } else {
611 main_data.gui = add_gui_layer(width, height);
612 }
613
614 clear_surface(main_data.gui->surface, NULL);
615
616 return TRUE;
617}
618
619/**********************************************************************/
622 void quit_sdl(void)
623{
624 FC_FREE(main_data.guis);
625 gui_layer_destroy(&main_data.gui);
626 FREESURFACE(main_data.map);
627 FREESURFACE(main_data.dummy);
628 SDL_DestroyTexture(main_data.maintext);
629
630 free_surfaces();
631}
632
633/**********************************************************************/
636 bool set_video_mode(unsigned width, unsigned height, unsigned flags_in)
637{
638 main_data.screen = SDL_CreateWindow(_("SDL2 Client for Freeciv"),
639 SDL_WINDOWPOS_UNDEFINED,
640 SDL_WINDOWPOS_UNDEFINED,
641 width, height,
642 0);
643
644 if (main_data.screen == NULL) {
645 log_fatal(_("Failed to create main window: %s"), SDL_GetError());
646 return FALSE;
647 }
648
649 if (flags_in & SDL_WINDOW_FULLSCREEN) {
650 SDL_DisplayMode mode;
651
652 /* Use SDL_WINDOW_FULLSCREEN_DESKTOP instead of real SDL_WINDOW_FULLSCREEN */
653 SDL_SetWindowFullscreen(main_data.screen, SDL_WINDOW_FULLSCREEN_DESKTOP);
654 SDL_GetWindowDisplayMode(main_data.screen, &mode);
655 width = mode.w;
656 height = mode.h;
657 }
658
659 if (!create_surfaces(width, height)) {
660 return FALSE;
661 }
662
663 return TRUE;
664}
665
666/**********************************************************************/
669 void update_main_screen(void)
670{
671 if (render_dirty) {
672 SDL_UpdateTexture(main_data.maintext, NULL,
673 main_surface->pixels, main_surface->pitch);
674 SDL_RenderClear(main_data.renderer);
675 SDL_RenderCopy(main_data.renderer, main_data.maintext, NULL, NULL);
676 SDL_RenderPresent(main_data.renderer);
677
678 render_dirty = FALSE;
679 }
680}
681
682/**********************************************************************/
685 int main_window_width(void)
686{
687 return main_surface->w;
688}
689
690/**********************************************************************/
693 int main_window_height(void)
694{
695 return main_surface->h;
696}
697
698/**************************************************************************
699 Fill Rect with RGBA color
700**************************************************************************/
701#define MASK565 0xf7de
702#define MASK555 0xfbde
703
704/* 50% alpha (128) */
705#define BLEND16_50( d, s , mask ) \
706 (((( s & mask ) + ( d & mask )) >> 1) + ( s & d & ( ~mask & 0xffff)))
707
708#define BLEND2x16_50( d, s , mask ) \
709 (((( s & (mask | mask << 16)) + ( d & ( mask | mask << 16 ))) >> 1) + \
710 ( s & d & ( ~(mask | mask << 16))))
711
712/**********************************************************************/
715 static int __FillRectAlpha8888_32bit(SDL_Surface *surf, SDL_Rect *prect,
716 SDL_Color *pcolor)
717{
718 register Uint32 A = pcolor->a;
719 register Uint32 dSIMD1, dSIMD2;
720 register Uint32 sSIMD1, sSIMD2 = SDL_MapRGB(surf->format,
721 pcolor->r, pcolor->g,
722 pcolor->b);
723 Uint32 y, end, A_Dst, A_Mask = surf->format->Amask;
724 Uint32 *start, *pixel;
725
726 sSIMD1 = sSIMD2 & 0x00FF00FF;
727
728 lock_surf(surf);
729
730 if (prect == NULL) {
731 end = surf->w * surf->h;
732 pixel = (Uint32 *) surf->pixels;
733 if (A == 128) { /* 50% A */
734 DUFFS_LOOP8(
735 {
736 dSIMD2 = *pixel;
737 A_Dst = dSIMD2 & A_Mask;
738 *pixel++ = ((((sSIMD2 & 0x00fefefe) + (dSIMD2 & 0x00fefefe)) >> 1)
739 + (sSIMD2 & dSIMD2 & 0x00010101)) | A_Dst;
740 }, end);
741 } else {
742 sSIMD2 &= 0xFF00;
743 sSIMD2 = sSIMD2 >> 8 | sSIMD2 << 8;
744 DUFFS_LOOP_DOUBLE2(
745 {
746 dSIMD2 = *pixel;
747 A_Dst = dSIMD2 & A_Mask;
748 dSIMD1 = dSIMD2 & 0x00FF00FF;
749 dSIMD1 += (sSIMD1 - dSIMD1) * A >> 8;
750 dSIMD1 &= 0x00FF00FF;
751 dSIMD2 &= 0xFF00;
752 dSIMD2 += (((sSIMD2 << 8) & 0xFF00) - dSIMD2) * A >> 8;
753 dSIMD2 &= 0xFF00;
754 *pixel++ = dSIMD1 | dSIMD2 | A_Dst;
755 }, {
756 dSIMD1 = *pixel;
757 A_Dst = dSIMD1 & A_Mask;
758 dSIMD1 &= 0x00FF00FF;
759 dSIMD1 += (sSIMD1 - dSIMD1) * A >> 8;
760 dSIMD1 &= 0x00FF00FF;
761
762 dSIMD2 = ((*pixel & 0xFF00) >> 8)| ((pixel[1] & 0xFF00) << 8);
763 dSIMD2 += (sSIMD2 - dSIMD2) * A >> 8;
764 dSIMD2 &= 0x00FF00FF;
765
766 *pixel++ = dSIMD1 | ((dSIMD2 << 8) & 0xFF00) | A_Dst;
767
768 dSIMD1 = *pixel;
769 A_Dst = dSIMD1 & A_Mask;
770 dSIMD1 &= 0x00FF00FF;
771 dSIMD1 += (sSIMD1 - dSIMD1) * A >> 8;
772 dSIMD1 &= 0x00FF00FF;
773
774 *pixel++ = dSIMD1 | ((dSIMD2 >> 8) & 0xFF00) | A_Dst;
775 }, end);
776 }
777 } else {
778 /* Correct prect size */
779 if (prect->x < 0) {
780 prect->w += prect->x;
781 prect->x = 0;
782 } else if (prect->x >= surf->w - prect->w) {
783 prect->w = surf->w - prect->x;
784 }
785
786 if (prect->y < 0) {
787 prect->h += prect->y;
788 prect->y = 0;
789 } else if (prect->y >= surf->h - prect->h) {
790 prect->h = surf->h - prect->y;
791 }
792
793 start = pixel = (Uint32 *) surf->pixels +
794 (prect->y * (surf->pitch >> 2)) + prect->x;
795
796 if (A == 128) { /* 50% A */
797 y = prect->h;
798 end = prect->w;
799 while (y--) {
800 DUFFS_LOOP4(
801 {
802 dSIMD2 = *pixel;
803 A_Dst = dSIMD2 & A_Mask;
804 *pixel++ = ((((sSIMD2 & 0x00fefefe) + (dSIMD2 & 0x00fefefe)) >> 1)
805 + (sSIMD2 & dSIMD2 & 0x00010101)) | A_Dst;
806 }, end);
807 pixel = start + (surf->pitch >> 2);
808 start = pixel;
809 }
810 } else {
811 y = prect->h;
812 end = prect->w;
813
814 sSIMD2 &= 0xFF00;
815 sSIMD2 = sSIMD2 >> 8 | sSIMD2 << 8;
816
817 while (y--) {
818 DUFFS_LOOP_DOUBLE2(
819 {
820 dSIMD2 = *pixel;
821 A_Dst = dSIMD2 & A_Mask;
822 dSIMD1 = dSIMD2 & 0x00FF00FF;
823 dSIMD1 += (sSIMD1 - dSIMD1) * A >> 8;
824 dSIMD1 &= 0x00FF00FF;
825 dSIMD2 &= 0xFF00;
826 dSIMD2 += (((sSIMD2 << 8) & 0xFF00) - dSIMD2) * A >> 8;
827 dSIMD2 &= 0xFF00;
828 *pixel++ = dSIMD1 | dSIMD2 | A_Dst;
829 }, {
830 dSIMD1 = *pixel;
831 A_Dst = dSIMD1 & A_Mask;
832 dSIMD1 &= 0x00FF00FF;
833 dSIMD1 += (sSIMD1 - dSIMD1) * A >> 8;
834 dSIMD1 &= 0x00FF00FF;
835
836 dSIMD2 = ((*pixel & 0xFF00) >> 8)| ((pixel[1] & 0xFF00) << 8);
837 dSIMD2 += (sSIMD2 - dSIMD2) * A >> 8;
838 dSIMD2 &= 0x00FF00FF;
839
840 *pixel++ = dSIMD1 | ((dSIMD2 << 8) & 0xFF00) | A_Dst;
841
842 dSIMD1 = *pixel;
843 A_Dst = dSIMD1 & A_Mask;
844 dSIMD1 &= 0x00FF00FF;
845 dSIMD1 += (sSIMD1 - dSIMD1) * A >> 8;
846 dSIMD1 &= 0x00FF00FF;
847
848 *pixel++ = dSIMD1 | ((dSIMD2 >> 8) & 0xFF00) | A_Dst;
849 }, end);
850
851 pixel = start + (surf->pitch >> 2);
852 start = pixel;
853 } /* while */
854 }
855 }
856
857 unlock_surf(surf);
858
859 return 0;
860}
861
862/**********************************************************************/
865 int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect,
866 SDL_Color *pcolor)
867{
868 if (prect && (prect->x < - prect->w || prect->x >= surf->w
869 || prect->y < - prect->h || prect->y >= surf->h)) {
870 return -2;
871 }
872
873 if (pcolor->a == 255) {
874 return SDL_FillRect(surf, prect,
875 SDL_MapRGB(surf->format, pcolor->r, pcolor->g, pcolor->b));
876 }
877
878 if (!pcolor->a) {
879 return -3;
880 }
881
882 return __FillRectAlpha8888_32bit(surf, prect, pcolor);
883}
884
885/**********************************************************************/
888 bool correct_rect_region(SDL_Rect *prect)
889{
890 int ww = prect->w, hh = prect->h;
891
892 if (prect->x < 0) {
893 ww += prect->x;
894 prect->x = 0;
895 }
896
897 if (prect->y < 0) {
898 hh += prect->y;
899 prect->y = 0;
900 }
901
902 if (prect->x + ww > main_window_width()) {
903 ww = main_window_width() - prect->x;
904 }
905
906 if (prect->y + hh > main_window_height()) {
907 hh = main_window_height() - prect->y;
908 }
909
910 /* End Correction */
911
912 if (ww <= 0 || hh <= 0) {
913 return FALSE; /* surprise :) */
914 } else {
915 prect->w = ww;
916 prect->h = hh;
917 }
918
919 return TRUE;
920}
921
922/**********************************************************************/
925 bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
926{
927 return ((x >= rect->x) && (x < rect-> x + rect->w)
928 && (y >= rect->y) && (y < rect-> y + rect->h));
929}
930
931/* ===================================================================== */
932
933/**********************************************************************/
936 void get_smaller_surface_rect(SDL_Surface *surf, SDL_Rect *rect)
937{
938 int w, h, x, y;
939 Uint16 minX, maxX, minY, maxY;
940 Uint32 colorkey;
941 Uint32 mask;
942
943 fc_assert(surf != NULL);
944 fc_assert(rect != NULL);
945
946 minX = surf->w;
947 maxX = 0;
948 minY = surf->h;
949 maxY = 0;
950
951 if (SDL_GetColorKey(surf, &colorkey) < 0) {
952 /* Use alpha instead of colorkey */
953 mask = surf->format->Amask;
954 colorkey = 0;
955 } else {
956 mask = 0xffffffff;
957 }
958
959 lock_surf(surf);
960
961 switch (surf->format->BytesPerPixel) {
962 case 1:
963 {
964 Uint8 *pixel = (Uint8 *)surf->pixels;
965 Uint8 *start = pixel;
966
967 x = 0;
968 y = 0;
969 w = surf->w;
970 h = surf->h;
971 while (h--) {
972 do {
973 if (*pixel != colorkey) {
974 if (minY > y) {
975 minY = y;
976 }
977
978 if (minX > x) {
979 minX = x;
980 }
981 break;
982 }
983 pixel++;
984 x++;
985 } while (--w > 0);
986 w = surf->w;
987 x = 0;
988 y++;
989 pixel = start + surf->pitch;
990 start = pixel;
991 }
992
993 w = surf->w;
994 h = surf->h;
995 x = w - 1;
996 y = h - 1;
997 pixel = (Uint8 *)((Uint8 *)surf->pixels + (y * surf->pitch) + x);
998 start = pixel;
999 while (h--) {
1000 do {
1001 if (*pixel != colorkey) {
1002 if (maxY < y) {
1003 maxY = y;
1004 }
1005
1006 if (maxX < x) {
1007 maxX = x;
1008 }
1009 break;
1010 }
1011 pixel--;
1012 x--;
1013 } while (--w > 0);
1014 w = surf->w;
1015 x = w - 1;
1016 y--;
1017 pixel = start - surf->pitch;
1018 start = pixel;
1019 }
1020 break;
1021 }
1022 case 2:
1023 {
1024 Uint16 *pixel = (Uint16 *)surf->pixels;
1025 Uint16 *start = pixel;
1026
1027 x = 0;
1028 y = 0;
1029 w = surf->w;
1030 h = surf->h;
1031 while (h--) {
1032 do {
1033 if (*pixel != colorkey) {
1034 if (minY > y) {
1035 minY = y;
1036 }
1037
1038 if (minX > x) {
1039 minX = x;
1040 }
1041 break;
1042 }
1043 pixel++;
1044 x++;
1045 } while (--w > 0);
1046 w = surf->w;
1047 x = 0;
1048 y++;
1049 pixel = start + surf->pitch / 2;
1050 start = pixel;
1051 }
1052
1053 w = surf->w;
1054 h = surf->h;
1055 x = w - 1;
1056 y = h - 1;
1057 pixel = ((Uint16 *)surf->pixels + (y * surf->pitch / 2) + x);
1058 start = pixel;
1059 while (h--) {
1060 do {
1061 if (*pixel != colorkey) {
1062 if (maxY < y) {
1063 maxY = y;
1064 }
1065
1066 if (maxX < x) {
1067 maxX = x;
1068 }
1069 break;
1070 }
1071 pixel--;
1072 x--;
1073 } while (--w > 0);
1074 w = surf->w;
1075 x = w - 1;
1076 y--;
1077 pixel = start - surf->pitch / 2;
1078 start = pixel;
1079 }
1080 break;
1081 }
1082 case 3:
1083 {
1084 Uint8 *pixel = (Uint8 *)surf->pixels;
1085 Uint8 *start = pixel;
1086 Uint32 color;
1087
1088 x = 0;
1089 y = 0;
1090 w = surf->w;
1091 h = surf->h;
1092 while (h--) {
1093 do {
1094 if (is_bigendian()) {
1095 color = (pixel[0] << 16 | pixel[1] << 8 | pixel[2]);
1096 } else {
1097 color = (pixel[0] | pixel[1] << 8 | pixel[2] << 16);
1098 }
1099 if (color != colorkey) {
1100 if (minY > y) {
1101 minY = y;
1102 }
1103
1104 if (minX > x) {
1105 minX = x;
1106 }
1107 break;
1108 }
1109 pixel += 3;
1110 x++;
1111 } while (--w > 0);
1112 w = surf->w;
1113 x = 0;
1114 y++;
1115 pixel = start + surf->pitch / 3;
1116 start = pixel;
1117 }
1118
1119 w = surf->w;
1120 h = surf->h;
1121 x = w - 1;
1122 y = h - 1;
1123 pixel = (Uint8 *)((Uint8 *)surf->pixels + (y * surf->pitch) + x * 3);
1124 start = pixel;
1125 while (h--) {
1126 do {
1127 if (is_bigendian()) {
1128 color = (pixel[0] << 16 | pixel[1] << 8 | pixel[2]);
1129 } else {
1130 color = (pixel[0] | pixel[1] << 8 | pixel[2] << 16);
1131 }
1132 if (color != colorkey) {
1133 if (maxY < y) {
1134 maxY = y;
1135 }
1136
1137 if (maxX < x) {
1138 maxX = x;
1139 }
1140 break;
1141 }
1142 pixel -= 3;
1143 x--;
1144 } while (--w > 0);
1145 w = surf->w;
1146 x = w - 1;
1147 y--;
1148 pixel = start - surf->pitch / 3;
1149 start = pixel;
1150 }
1151 break;
1152 }
1153 case 4:
1154 {
1155 Uint32 *pixel = (Uint32 *)surf->pixels;
1156 Uint32 *start = pixel;
1157
1158 x = 0;
1159 y = 0;
1160 w = surf->w;
1161 h = surf->h;
1162 while (h--) {
1163 do {
1164 if (((*pixel) & mask) != colorkey) {
1165 if (minY > y) {
1166 minY = y;
1167 }
1168
1169 if (minX > x) {
1170 minX = x;
1171 }
1172 break;
1173 }
1174 pixel++;
1175 x++;
1176 } while (--w > 0);
1177 w = surf->w;
1178 x = 0;
1179 y++;
1180 pixel = start + surf->pitch / 4;
1181 start = pixel;
1182 }
1183
1184 w = surf->w;
1185 h = surf->h;
1186 x = w - 1;
1187 y = h - 1;
1188 pixel = ((Uint32 *)surf->pixels + (y * surf->pitch / 4) + x);
1189 start = pixel;
1190 while (h--) {
1191 do {
1192 if (((*pixel) & mask) != colorkey) {
1193 if (maxY < y) {
1194 maxY = y;
1195 }
1196
1197 if (maxX < x) {
1198 maxX = x;
1199 }
1200 break;
1201 }
1202 pixel--;
1203 x--;
1204 } while (--w > 0);
1205 w = surf->w;
1206 x = w - 1;
1207 y--;
1208 pixel = start - surf->pitch / 4;
1209 start = pixel;
1210 }
1211 break;
1212 }
1213 }
1214
1215 unlock_surf(surf);
1216 rect->x = minX;
1217 rect->y = minY;
1218 rect->w = maxX - minX + 1;
1219 rect->h = maxY - minY + 1;
1220}
1221
1222/**********************************************************************/
1225 SDL_Surface *crop_visible_part_from_surface(SDL_Surface *psrc)
1226{
1227 SDL_Rect src;
1228
1229 get_smaller_surface_rect(psrc, &src);
1230
1231 return crop_rect_from_surface(psrc, &src);
1232}
1233
1234/**********************************************************************/
1237 SDL_Surface *resize_surface(const SDL_Surface *psrc, Uint16 new_width,
1238 Uint16 new_height, int smooth)
1239{
1240 if (psrc == NULL) {
1241 return NULL;
1242 }
1243
1244 return zoomSurface((SDL_Surface*)psrc,
1245 (double)new_width / psrc->w,
1246 (double)new_height / psrc->h,
1247 smooth);
1248}
1249
1250/**********************************************************************/
1257 SDL_Surface *resize_surface_box(const SDL_Surface *psrc,
1258 Uint16 new_width, Uint16 new_height,
1259 int smooth, bool scale_up,
1260 bool absolute_dimensions)
1261{
1262 SDL_Surface *tmp_surface, *result;
1263
1264 if (psrc == NULL) {
1265 return NULL;
1266 }
1267
1268 if (!(!scale_up && ((new_width >= psrc->w) && (new_height >= psrc->h)))) {
1269 if ((new_width - psrc->w) <= (new_height - psrc->h)) {
1270 /* horizontal limit */
1271 tmp_surface = zoomSurface((SDL_Surface*)psrc,
1272 (double)new_width / psrc->w,
1273 (double)new_width / psrc->w,
1274 smooth);
1275 } else {
1276 /* vertical limit */
1277 tmp_surface = zoomSurface((SDL_Surface*)psrc,
1278 (double)new_height / psrc->h,
1279 (double)new_height / psrc->h,
1280 smooth);
1281 }
1282 } else {
1283 tmp_surface = zoomSurface((SDL_Surface*)psrc,
1284 1.0,
1285 1.0,
1286 smooth);
1287 }
1288
1289 if (absolute_dimensions) {
1290 SDL_Rect area = {
1291 (new_width - tmp_surface->w) / 2,
1292 (new_height - tmp_surface->h) / 2,
1293 0, 0
1294 };
1295
1296 result = create_surf(new_width, new_height, SDL_SWSURFACE);
1297 alphablit(tmp_surface, NULL, result, &area, 255);
1298 FREESURFACE(tmp_surface);
1299 } else {
1300 result = tmp_surface;
1301 }
1302
1303 return result;
1304}
1305
1306/**********************************************************************/
1309 SDL_Surface *copy_surface(SDL_Surface *src)
1310{
1311 SDL_Surface *dst;
1312
1313 dst = SDL_CreateRGBSurface(0, src->w, src->h, src->format->BitsPerPixel,
1314 src->format->Rmask, src->format->Gmask,
1315 src->format->Bmask, src->format->Amask);
1316
1317 SDL_BlitSurface(src, NULL, dst, NULL);
1318
1319 return dst;
1320}
1321
1322/* ============ Freeciv game graphics function =========== */
1323
1324/**********************************************************************/
1327 bool is_view_supported(enum ts_type type)
1328{
1329 switch (type) {
1330 case TS_ISOMETRIC:
1331 case TS_OVERHEAD:
1332 return TRUE;
1333 case TS_3D:
1334 return FALSE;
1335 }
1336
1337 return FALSE;
1338}
1339
1340/**********************************************************************/
1343 void tileset_type_set(enum ts_type type)
1344{
1345}
1346
1347/**********************************************************************/
1350 void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top,
1351 Sint16 width, Sint16 height,
1352 SDL_Color *pcolor)
1353{
1354 struct color gsdl2_color = { .color = pcolor };
1355 struct sprite *vertical = create_sprite(1, height, &gsdl2_color);
1356 struct sprite *horizontal = create_sprite(width, 1, &gsdl2_color);
1357 SDL_Rect tmp, dst = { .x = left, .y = top, .w = 0, .h = 0 };
1358
1359 tmp = dst;
1360 alphablit(vertical->psurface, NULL, dest, &tmp, 255);
1361
1362 dst.x += width - 1;
1363 tmp = dst;
1364 alphablit(vertical->psurface, NULL, dest, &tmp, 255);
1365
1366 dst.x = left;
1367 tmp = dst;
1368 alphablit(horizontal->psurface, NULL, dest, &tmp, 255);
1369
1370 dst.y += height - 1;
1371 tmp = dst;
1372 alphablit(horizontal->psurface, NULL, dest, &tmp, 255);
1373
1374 free_sprite(horizontal);
1375 free_sprite(vertical);
1376}
1377
1378/**********************************************************************/
1381 void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1,
1382 SDL_Color *pcolor)
1383{
1384 int xl = x0 < x1 ? x0 : x1;
1385 int xr = x0 < x1 ? x1 : x0;
1386 int yt = y0 < y1 ? y0 : y1;
1387 int yb = y0 < y1 ? y1 : y0;
1388 int w = (xr - xl) + 1;
1389 int h = (yb - yt) + 1;
1390 struct sprite *spr;
1391 SDL_Rect dst = { xl, yt, w, h };
1392 SDL_Color *pcol;
1393 struct color gsdl2_color;
1394 int l = MAX((xr - xl) + 1, (yb - yt) + 1);
1395 int i;
1396
1397 pcol = fc_malloc(sizeof(pcol));
1398 pcol->r = pcolor->r;
1399 pcol->g = pcolor->g;
1400 pcol->b = pcolor->b;
1401 pcol->a = 0; /* Fill with transparency */
1402
1403 gsdl2_color.color = pcol;
1404 spr = create_sprite(w, h, &gsdl2_color);
1405
1406 lock_surf(spr->psurface);
1407
1408 /* Set off transparency from pixels belonging to the line */
1409 if ((x0 <= x1 && y0 <= y1)
1410 || (x1 <= x0 && y1 <= y0)) {
1411 for (i = 0; i < l; i++) {
1412 int cx = (xr - xl) * i / l;
1413 int cy = (yb - yt) * i / l;
1414
1415 *((Uint32 *)spr->psurface->pixels + spr->psurface->w * cy + cx)
1416 |= (pcolor->a << spr->psurface->format->Ashift);
1417 }
1418 } else {
1419 for (i = 0; i < l; i++) {
1420 int cx = (xr - xl) * i / l;
1421 int cy = yb - yt - (yb - yt) * i / l;
1422
1423 *((Uint32 *)spr->psurface->pixels + spr->psurface->w * cy + cx)
1424 |= (pcolor->a << spr->psurface->format->Ashift);
1425 }
1426 }
1427
1428 unlock_surf(spr->psurface);
1429
1430 alphablit(spr->psurface, NULL, dest, &dst, 255);
1431
1432 free_sprite(spr);
1433 free(pcol);
1434}
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
pcolor
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
incite_cost
char * incite_cost
Definition comments.c:74
fcintl.h
_
#define _(String)
Definition fcintl.h:67
is_view_supported
bool is_view_supported(enum ts_type type)
Definition graphics.c:53
tileset_type_set
void tileset_type_set(enum ts_type type)
Definition graphics.c:73
type
GType type
Definition repodlgs.c:1313
free_sprite
void free_sprite(struct sprite *s)
Definition sprite.c:278
create_sprite
struct sprite * create_sprite(int width, int height, struct color *pcolor)
Definition sprite.c:84
resize_surface
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
set_video_mode
bool set_video_mode(unsigned width, unsigned height, unsigned flags_in)
Definition graphics.c:636
getpixel
Uint32 getpixel(SDL_Surface *surf, Sint16 x, Sint16 y)
Definition graphics.c:430
main_window_width
int main_window_width(void)
Definition graphics.c:685
layer_rect_to_screen_rect
void layer_rect_to_screen_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
Definition graphics.c:185
load_surf
SDL_Surface * load_surf(const char *fname)
Definition graphics.c:307
create_surf_with_format
SDL_Surface * create_surf_with_format(SDL_PixelFormat *pf, int width, int height, Uint32 flags)
Definition graphics.c:328
init_sdl
void init_sdl(int flags)
Definition graphics.c:506
update_main_screen
void update_main_screen(void)
Definition graphics.c:669
remove_gui_layer
void remove_gui_layer(struct gui_layer *gui_layer)
Definition graphics.c:148
create_filled_surface
SDL_Surface * create_filled_surface(Uint16 w, Uint16 h, Uint32 flags, SDL_Color *pcolor)
Definition graphics.c:368
fill_rect_alpha
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
gui_layer_destroy
void gui_layer_destroy(struct gui_layer **gui_layer)
Definition graphics.c:81
create_line
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1381
copy_surface
SDL_Surface * copy_surface(SDL_Surface *src)
Definition graphics.c:1309
mask_surface
SDL_Surface * mask_surface(SDL_Surface *src, SDL_Surface *mask, int mask_offset_x, int mask_offset_y)
Definition graphics.c:262
gui_layer_new
struct gui_layer * gui_layer_new(int x, int y, SDL_Surface *surface)
Definition graphics.c:66
quit_sdl
void quit_sdl(void)
Definition graphics.c:622
crop_visible_part_from_surface
SDL_Surface * crop_visible_part_from_surface(SDL_Surface *psrc)
Definition graphics.c:1225
crop_rect_from_surface
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
alphablit
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
get_gui_layer
struct gui_layer * get_gui_layer(SDL_Surface *surface)
Definition graphics.c:90
is_in_rect_area
bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
Definition graphics.c:925
screen_blit
int screen_blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:223
main_data
struct sdl2_data main_data
Definition graphics.c:57
main_surface
static SDL_Surface * main_surface
Definition graphics.c:59
blit_entire_src
int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Definition graphics.c:417
get_first_pixel
Uint32 get_first_pixel(SDL_Surface *surf)
Definition graphics.c:468
convert_surf
SDL_Surface * convert_surf(SDL_Surface *surf_in)
Definition graphics.c:359
create_surf
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
get_smaller_surface_rect
void get_smaller_surface_rect(SDL_Surface *surf, SDL_Rect *rect)
Definition graphics.c:936
add_gui_layer
struct gui_layer * add_gui_layer(int width, int height)
Definition graphics.c:112
clear_surface
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:400
correct_rect_region
bool correct_rect_region(SDL_Rect *prect)
Definition graphics.c:888
screen_rect_to_layer_rect
void screen_rect_to_layer_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
Definition graphics.c:173
__FillRectAlpha8888_32bit
static int __FillRectAlpha8888_32bit(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:715
create_frame
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1350
free_surfaces
static void free_surfaces(void)
Definition graphics.c:543
create_surfaces
bool create_surfaces(int width, int height)
Definition graphics.c:556
main_window_height
int main_window_height(void)
Definition graphics.c:693
render_dirty
static bool render_dirty
Definition graphics.c:61
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)
Definition graphics.c:1257
FREESURFACE
#define FREESURFACE(ptr)
Definition graphics.h:322
unlock_surf
#define unlock_surf(surf)
Definition graphics.h:344
lock_surf
#define lock_surf(surf)
Definition graphics.h:333
DUFFS_LOOP_DOUBLE2
#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment, double_pixel_copy_increment, width)
Definition graphics.h:98
DUFFS_LOOP8
#define DUFFS_LOOP8(pixel_copy_increment, width)
Definition graphics.h:60
DUFFS_LOOP4
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition graphics.h:83
sdl2_client_flags
Uint32 sdl2_client_flags
Definition gui_main.c:101
CF_SWRENDERER
#define CF_SWRENDERER
Definition gui_main.h:64
GUI_SDL_OPTION
#define GUI_SDL_OPTION(optname)
Definition gui_main.h:37
gui_tilespec.h
themebackgrounds.h
themespec.h
colors.h
graphics.h
mapview.h
log.h
fc_assert
#define fc_assert(condition)
Definition log.h:176
log_fatal
#define log_fatal(message,...)
Definition log.h:100
log_error
#define log_error(message,...)
Definition log.h:103
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_realloc
#define fc_realloc(ptr, sz)
Definition mem.h:36
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
MAX
#define MAX(x, y)
Definition shared.h:54
mask
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
y
struct sprite int int y
Definition sprite_g.h:31
mask_offset_x
struct sprite int int int int struct sprite int mask_offset_x
Definition sprite_g.h:32
x
struct sprite int x
Definition sprite_g.h:31
mask_offset_y
struct sprite int int int int struct sprite int int mask_offset_y
Definition sprite_g.h:32
color
Definition colors.h:21
color::color
GdkRGBA color
Definition colors.h:22
gui_layer
Definition graphics.h:227
gui_layer::surface
SDL_Surface * surface
Definition graphics.h:229
gui_layer::dest_rect
SDL_Rect dest_rect
Definition graphics.h:228
sdl2_data
Definition graphics.h:205
sdl2_data::guis_count
int guis_count
Definition graphics.h:207
sdl2_data::dummy
SDL_Surface * dummy
Definition graphics.h:211
sdl2_data::renderer
SDL_Renderer * renderer
Definition graphics.h:213
sdl2_data::maintext
SDL_Texture * maintext
Definition graphics.h:212
sdl2_data::gui
struct gui_layer * gui
Definition graphics.h:215
sdl2_data::rects_count
int rects_count
Definition graphics.h:206
sdl2_data::guis
struct gui_layer ** guis
Definition graphics.h:216
sdl2_data::screen
SDL_Window * screen
Definition graphics.h:209
sdl2_data::map
SDL_Surface * map
Definition graphics.h:210
sprite
Definition sprite.h:22
is_bigendian
static bool is_bigendian(void)
Definition support.h:229
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tilespec.h