diff --git display/simgraph16.cc display/simgraph16.cc index e55b77065..37777a9a7 100644 --- display/simgraph16.cc +++ display/simgraph16.cc @@ -39,6 +39,7 @@ // currently just redrawing/rezooming static pthread_mutex_t rezoom_img_mutex[MAX_THREADS]; static pthread_mutex_t recode_img_mutex; +static pthread_mutex_t dirty_img_mutex; //< for marking tile as dirty #endif // to pass the extra clipnum when not needed use this @@ -1014,6 +1015,8 @@ static void mark_rect_dirty_nc(KOORD_VAL x1, KOORD_VAL y1, KOORD_VAL x2, KOORD_V assert(y2 < tile_lines); #endif + pthread_mutex_lock(&dirty_img_mutex); + for( ; y1 <= y2; y1++ ) { int bit = y1 * tile_buffer_per_line + x1; const int end = bit + x2 - x1; @@ -1021,6 +1024,8 @@ static void mark_rect_dirty_nc(KOORD_VAL x1, KOORD_VAL y1, KOORD_VAL x2, KOORD_V tile_dirty[bit >> 5] |= 1 << (bit & 31); } while( ++bit <= end ); } + + pthread_mutex_unlock(&dirty_img_mutex); } @@ -5052,6 +5057,7 @@ void simgraph_init(KOORD_VAL width, KOORD_VAL height, int full_screen) #ifdef MULTI_THREAD pthread_mutex_init( &recode_img_mutex, NULL ); + pthread_mutex_init( &dirty_img_mutex, NULL ); #endif // init rezoom_img() @@ -5182,6 +5188,7 @@ void simgraph_exit() tile_dirty = tile_dirty_old = NULL; images = NULL; #ifdef MULTI_THREAD + pthread_mutex_destroy( &dirty_img_mutex ); pthread_mutex_destroy( &recode_img_mutex ); for( int i = 0; i < MAX_THREADS; i++ ) { pthread_mutex_destroy( &rezoom_img_mutex[i] );