added some performance tuning for "autotest" and warp mode
authorHolger Schemel <info@artsoft.org>
Tue, 6 Feb 2018 21:15:15 +0000 (22:15 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 6 Feb 2018 21:34:44 +0000 (22:34 +0100)
- 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
src/game_em/graphics.c
src/game_sp/main.c
src/libgame/system.c
src/libgame/system.h

index b8d863fe232597b2b32f3c43132b2d10c6255980..e159b96ef2183c7d6c73aed8c0f709872fefe5d6 100644 (file)
@@ -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]);
 
index 727b2b84ae536f5d8246600e8669aacdbc3d4bc7..07a965dd1cba1f7457b0de9c6efe0611bbc9f7cf 100644 (file)
@@ -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 =
index 3373d46085fe9ddee101e4737914f95f34b39501..c7239cc80ed0371faa5ef8651877dd5bb75e2418 100644 (file)
@@ -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();
 
index a87ecc837f15206351dd228e89bedcf25512a925..6f063d1c01b0d79df41f2989b8d4dec35bae12a0 100644 (file)
@@ -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);
index 3cf8bea6231c944b36ec44102233a4928560f403..efc4490d7e2fdaf65e9d6b92349ea44459007a8f 100644 (file)
@@ -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();