Fix problems drawing color selectors in background thread w/Allegro back-end

In debug mode Aseprite can crashes, in release mode the effect is only
visual: if the palette contains semi-transparent colors, the Allegro
drawing mode is changed while drawing the color bar and the color
selector will use the new drawing mode (or vice-versa).

Bug introduced in 0fe5edb7fea9d55257e227b7063d892e4350e3a3
This commit is contained in:
David Capello 2018-05-31 15:38:51 -03:00
parent 0c7c1b13ec
commit 594fe3fb90
3 changed files with 20 additions and 12 deletions

View File

@ -100,6 +100,14 @@ typedef struct _DRIVER_INFO /* info about a hardware driver */
int autodetect; /* set to allow autodetection */
} _DRIVER_INFO;
#ifdef _MSC_VER
#define ALLEGRO_TLS __declspec(thread)
#elif __GNUC__
#define ALLEGRO_TLS __thread
#else
#define ALLEGRO_TLS
#endif
#ifdef __cplusplus
}
#endif

View File

@ -362,12 +362,12 @@ AL_VAR(int, _dispsw_status);
/* current drawing mode */
AL_VAR(int, _drawing_mode);
AL_VAR(BITMAP *, _drawing_pattern);
AL_VAR(int, _drawing_x_anchor);
AL_VAR(int, _drawing_y_anchor);
AL_VAR(unsigned int, _drawing_x_mask);
AL_VAR(unsigned int, _drawing_y_mask);
AL_VAR(ALLEGRO_TLS int, _drawing_mode);
AL_VAR(ALLEGRO_TLS BITMAP *, _drawing_pattern);
AL_VAR(ALLEGRO_TLS int, _drawing_x_anchor);
AL_VAR(ALLEGRO_TLS int, _drawing_y_anchor);
AL_VAR(ALLEGRO_TLS unsigned int, _drawing_x_mask);
AL_VAR(ALLEGRO_TLS unsigned int, _drawing_y_mask);
AL_FUNCPTR(int *, _palette_expansion_table, (int bpp));

View File

@ -77,15 +77,15 @@ BITMAP *screen = NULL;
/* info about the current graphics drawing mode */
int _drawing_mode = DRAW_MODE_SOLID;
ALLEGRO_TLS int _drawing_mode = DRAW_MODE_SOLID;
BITMAP *_drawing_pattern = NULL;
ALLEGRO_TLS BITMAP *_drawing_pattern = NULL;
int _drawing_x_anchor = 0;
int _drawing_y_anchor = 0;
ALLEGRO_TLS int _drawing_x_anchor = 0;
ALLEGRO_TLS int _drawing_y_anchor = 0;
unsigned int _drawing_x_mask = 0;
unsigned int _drawing_y_mask = 0;
ALLEGRO_TLS unsigned int _drawing_x_mask = 0;
ALLEGRO_TLS unsigned int _drawing_y_mask = 0;
/* default palette structures */