From 727d3b5fc7cac6f59652eaa23f1ed9e991ae50bd Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 6 Feb 2018 22:15:15 +0100 Subject: [PATCH] added some performance tuning for "autotest" and warp mode - profiling showed that completely skipping the playfield redraw functions makes "autotest" and warp mode much (or at least considerably) faster in certain cases than only skipping the resulting bitmap blitting functions - massive speedup when using the EM engine with the R'n'D graphics engine - good speedup when using the EM engine with the native EM graphics engine - good speedup when using the SP engine - minor speedup when using the R'n'D engine --- src/game.c | 4 ++++ src/game_em/graphics.c | 4 ++++ src/game_sp/main.c | 4 ++++ src/libgame/system.c | 11 +++++++++++ src/libgame/system.h | 1 + 5 files changed, 24 insertions(+) diff --git a/src/game.c b/src/game.c index b8d863fe..e159b96e 100644 --- a/src/game.c +++ b/src/game.c @@ -4599,6 +4599,10 @@ void InitPlayerGfxAnimation(struct PlayerInfo *player, int action, int dir) static void ResetGfxFrame(int x, int y) { + // profiling showed that "autotest" spends 10~20% of its time in this function + if (DrawingDeactivatedField()) + return; + int element = Feld[x][y]; int graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]); diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 727b2b84..07a965dd 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -544,6 +544,10 @@ static boolean checkIfAllPlayersAreVisible(int center_x, int center_y) void RedrawPlayfield_EM(boolean force_redraw) { + // skip redrawing playfield in warp mode or when testing tapes with "autotest" + if (DrawingDeactivatedField()) + return; + boolean draw_new_player_location = FALSE; boolean quick_relocation = setup.quick_switch; int max_center_distance_player_nr = diff --git a/src/game_sp/main.c b/src/game_sp/main.c index 3373d460..c7239cc8 100644 --- a/src/game_sp/main.c +++ b/src/game_sp/main.c @@ -54,6 +54,10 @@ void InitGameEngine_SP() void RedrawPlayfield_SP(boolean force_redraw) { + // skip redrawing playfield in warp mode or when testing tapes with "autotest" + if (DrawingDeactivatedField()) + return; + if (force_redraw) RestorePlayfield(); diff --git a/src/libgame/system.c b/src/libgame/system.c index a87ecc83..6f063d1c 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -600,6 +600,17 @@ inline static boolean CheckDrawingArea(int x, int y, int width, int height, return FALSE; } +boolean DrawingDeactivatedField() +{ + if (program.headless) + return TRUE; + + if (gfx.draw_deactivation_mask & REDRAW_FIELD) + return TRUE; + + return FALSE; +} + boolean DrawingDeactivated(int x, int y, int width, int height) { return CheckDrawingArea(x, y, width, height, gfx.draw_deactivation_mask); diff --git a/src/libgame/system.h b/src/libgame/system.h index 3cf8bea6..efc4490d 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1505,6 +1505,7 @@ void FillRectangle(Bitmap *, int, int, int, int, Pixel); void ClearRectangle(Bitmap *, int, int, int, int); void ClearRectangleOnBackground(Bitmap *, int, int, int, int); void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int); +boolean DrawingDeactivatedField(void); boolean DrawingDeactivated(int, int, int, int); boolean DrawingOnBackground(int, int); boolean DrawingAreaChanged(); -- 2.34.1