From: Holger Schemel Date: Thu, 21 May 2015 09:53:46 +0000 (+0200) Subject: added generically setting redraw mask when blitting to backbuffer X-Git-Tag: 4.0.0.0-rc1~189 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7bb765525399cc21e982a9f00f6340ef82eb5da3;p=rocksndiamonds.git added generically setting redraw mask when blitting to backbuffer --- diff --git a/src/libgame/system.c b/src/libgame/system.c index f0d73e73..3bd825fd 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -319,9 +319,12 @@ inline static int GetRealDepth(int depth) } inline static void sysFillRectangle(Bitmap *bitmap, int x, int y, - int width, int height, Pixel color) + int width, int height, Pixel color) { SDLFillRectangle(bitmap, x, y, width, height, color); + + if (bitmap == backbuffer) + SetRedrawMaskFromArea(x, y, width, height); } inline static void sysCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, @@ -330,6 +333,9 @@ inline static void sysCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, { SDLCopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height, dst_x, dst_y, mask_mode); + + if (dst_bitmap == backbuffer) + SetRedrawMaskFromArea(dst_x, dst_y, width, height); } void LimitScreenUpdates(boolean enable) @@ -438,6 +444,28 @@ void CloseWindow(DrawWindow *window) { } +void SetRedrawMaskFromArea(int x, int y, int width, int height) +{ + int x1 = x; + int y1 = y; + int x2 = x + width - 1; + int y2 = y + height - 1; + + if (width == 0 || height == 0) + return; + + if (IN_GFX_FIELD_FULL(x1, y1) && IN_GFX_FIELD_FULL(x2, y2)) + redraw_mask |= REDRAW_FIELD; + else if (IN_GFX_DOOR_1(x1, y1) && IN_GFX_DOOR_1(x2, y2)) + redraw_mask |= REDRAW_DOOR_1; + else if (IN_GFX_DOOR_2(x1, y1) && IN_GFX_DOOR_2(x2, y2)) + redraw_mask |= REDRAW_DOOR_2; + else if (IN_GFX_DOOR_3(x1, y1) && IN_GFX_DOOR_3(x2, y2)) + redraw_mask |= REDRAW_DOOR_3; + else + redraw_mask = REDRAW_ALL; +} + inline static boolean CheckDrawingArea(int x, int y, int width, int height, int draw_mask) { diff --git a/src/libgame/system.h b/src/libgame/system.h index 85ab383f..9a42c147 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1313,6 +1313,7 @@ void SetDrawBackgroundMask(int); void SetWindowBackgroundBitmap(Bitmap *); void SetMainBackgroundBitmap(Bitmap *); void SetDoorBackgroundBitmap(Bitmap *); +void SetRedrawMaskFromArea(int, int, int, int); void LimitScreenUpdates(boolean);