rnd-20140117-1-src
authorHolger Schemel <info@artsoft.org>
Fri, 17 Jan 2014 15:55:52 +0000 (16:55 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:00:38 +0000 (11:00 +0200)
* improved speed of displaying progress when loading levels and artwork

ChangeLog
src/conftime.h
src/init.c
src/libgame/sdl.c
src/libgame/sdl.h
src/libgame/system.c
src/libgame/system.h
src/libgame/text.c
src/libgame/text.h
src/screens.c

index 03bb49af446533d6d01c6363636fe47e8e0d4996..c1e55e2650b96625977b9e81fd72d2b6ae17364c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2014-01-17
+       * improved speed of displaying progress when loading levels and artwork
+
 2014-01-15
        * fixed toons stopping on continuous touch events on Mac OS X
 
index db55b7e10143865ebb7e0dd3f6d28fa6a5288569..a77246756d672e97abd37d350c154549031e138f 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2014-01-15 20:15"
+#define COMPILE_DATE_STRING "2014-01-17 16:49"
index 723f8af0e2597b1a5924c86104ed4e365cb0b5f6..a1b92d253eb63a7cd292fa64459d6b72574cecfa 100644 (file)
@@ -5593,14 +5593,15 @@ void InitGfx()
   font_height = getFontHeight(FC_RED);
 
 #if 1
-  DrawInitText(getWindowTitleString(), 20, FC_YELLOW);
+  DrawInitTextAlways(getWindowTitleString(), 20, FC_YELLOW);
 #else
-  DrawInitText(getProgramInitString(), 20, FC_YELLOW);
+  DrawInitTextAlways(getProgramInitString(), 20, FC_YELLOW);
 #endif
-  DrawInitText(PROGRAM_COPYRIGHT_STRING, 50, FC_RED);
-  DrawInitText(PROGRAM_WEBSITE_STRING, WIN_YSIZE - 20 - font_height, FC_RED);
+  DrawInitTextAlways(PROGRAM_COPYRIGHT_STRING, 50, FC_RED);
+  DrawInitTextAlways(PROGRAM_WEBSITE_STRING, WIN_YSIZE - 20 - font_height,
+                    FC_RED);
 
-  DrawInitText("Loading graphics", 120, FC_GREEN);
+  DrawInitTextAlways("Loading graphics", 120, FC_GREEN);
 
 #if 1
 #if 1
@@ -6216,6 +6217,8 @@ void ReloadCustomArtwork(int force_reload)
 #endif
 
   print_timestamp_done("ReloadCustomArtwork");
+
+  LimitScreenUpdates(FALSE);
 }
 
 void KeyboardAutoRepeatOffUnlessAutoplay()
index 4fd21a304494c6fda4b4e5d63135da4644f41430..123916520339578ec0cea14ece88db5e1ce0c17f 100644 (file)
@@ -40,13 +40,31 @@ static int fullscreen_xoffset;
 static int fullscreen_yoffset;
 static int video_xoffset;
 static int video_yoffset;
+static boolean limit_screen_updates = FALSE;
+
 
 /* functions from SGE library */
 void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32);
 
-#if defined(TARGET_SDL2)
+void SDLLimitScreenUpdates(boolean enable)
+{
+  limit_screen_updates = enable;
+}
+
 static void UpdateScreen(SDL_Rect *rect)
 {
+  static unsigned int update_screen_delay = 0;
+  unsigned int update_screen_delay_value = 100;                /* (milliseconds) */
+
+#if 1
+  if (limit_screen_updates &&
+      !DelayReached(&update_screen_delay, update_screen_delay_value))
+    return;
+
+  LimitScreenUpdates(FALSE);
+#endif
+
+#if defined(TARGET_SDL2)
 #if USE_RENDERER
   SDL_Surface *screen = backbuffer->surface;
 
@@ -79,8 +97,14 @@ static void UpdateScreen(SDL_Rect *rect)
   else
     SDL_UpdateWindowSurface(sdl_window);
 #endif
-}
+
+#else  // TARGET_SDL
+  if (rect)
+    SDL_UpdateRects(backbuffer->surface, 1, rect);
+  else
+    SDL_UpdateRect(backbuffer->surface, 0, 0, 0, 0);
 #endif
+}
 
 static void setFullscreenParameters(char *fullscreen_mode_string)
 {
@@ -391,9 +415,9 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer,
                                    boolean fullscreen)
 {
   SDL_Surface *new_surface = NULL;
-  static boolean fullscreen_enabled = FALSE;
 
 #if defined(TARGET_SDL2)
+  static boolean fullscreen_enabled = FALSE;
   int surface_flags_window = SURFACE_FLAGS | SDL_WINDOW_RESIZABLE;
 #if USE_DESKTOP_FULLSCREEN
   int surface_flags_fullscreen = SURFACE_FLAGS | SDL_WINDOW_FULLSCREEN_DESKTOP;
@@ -559,9 +583,11 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer,
   new_surface = SDL_SetVideoMode(width, height, video.depth, surface_flags);
 #endif
 
+#if defined(TARGET_SDL2)
   // store fullscreen state ("video.fullscreen_enabled" may not reflect this!)
   if (new_surface != NULL)
     fullscreen_enabled = fullscreen;
+#endif
 
   return new_surface;
 }
@@ -934,7 +960,10 @@ void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
   }
 #else
   if (dst_bitmap == window)
-    SDL_UpdateRect(backbuffer->surface, dst_x, dst_y, width, height);
+  {
+    // SDL_UpdateRect(backbuffer->surface, dst_x, dst_y, width, height);
+    UpdateScreen(&dst_rect);
+  }
 #endif
 }
 
@@ -966,7 +995,10 @@ void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, int width, int height,
   }
 #else
   if (dst_bitmap == window)
-    SDL_UpdateRect(backbuffer->surface, x, y, width, height);
+  {
+    // SDL_UpdateRect(backbuffer->surface, x, y, width, height);
+    UpdateScreen(&rect);
+  }
 #endif
 }
 
@@ -981,9 +1013,7 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
   SDL_Surface *surface_screen = backbuffer->surface;
   SDL_Surface *surface_cross = (bitmap_cross ? bitmap_cross->surface : NULL);
   SDL_Rect src_rect, dst_rect;
-#if defined(TARGET_SDL2)
   SDL_Rect dst_rect2;
-#endif
   int src_x = x, src_y = y;
   int dst_x = x, dst_y = y;
   unsigned int time_last, time_current;
@@ -1012,9 +1042,7 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
   dst_rect.w = width;          /* (ignored) */
   dst_rect.h = height;         /* (ignored) */
 
-#if defined(TARGET_SDL2)
   dst_rect2 = dst_rect;
-#endif
 
   if (initialization_needed)
   {
@@ -1215,7 +1243,8 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
        // SDL_UpdateWindowSurfaceRects(sdl_window, &dst_rect2, 1);
        UpdateScreen(&dst_rect2);
 #else
-       SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height);
+       // SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height);
+       UpdateScreen(&dst_rect2);
 #endif
       }
     }
@@ -1254,7 +1283,8 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
       // SDL_UpdateWindowSurfaceRects(sdl_window, &dst_rect, 1);
       UpdateScreen(&dst_rect);
 #else
-      SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height);
+      // SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height);
+      UpdateScreen(&dst_rect);
 #endif
 #else
       SDL_Flip(surface_screen);
index 05ddfed6ac406c974bb368e6bfbbd390d095239e..710d247c6e96d24a5ec664ad04bbae35f69d4686 100644 (file)
@@ -442,6 +442,7 @@ void SDLSetWindowFullscreen(boolean);
 void SDLRedrawWindow();
 #endif
 
+void SDLLimitScreenUpdates(boolean);
 void SDLInitVideoDisplay(void);
 void SDLInitVideoBuffer(DrawBuffer **, DrawWindow **, boolean);
 boolean SDLSetVideoMode(DrawBuffer **, boolean);
index 6bc36f961d657070221cf508db993210fff49aff..94fe631b87a12e3f421dbf0b6148fc55443ce23d 100644 (file)
@@ -415,6 +415,13 @@ inline static void sysCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
 #endif
 }
 
+void LimitScreenUpdates(boolean enable)
+{
+#if defined(TARGET_SDL)
+  SDLLimitScreenUpdates(enable);
+#endif
+}
+
 void InitVideoDisplay(void)
 {
 #if defined(TARGET_SDL)
index abb63b591e70c039d3dface2849e1abb5b0d05d1..95076061b8f175cb6c167c25cd559f4675cad8aa 100644 (file)
@@ -1276,6 +1276,8 @@ void SetWindowBackgroundBitmap(Bitmap *);
 void SetMainBackgroundBitmap(Bitmap *);
 void SetDoorBackgroundBitmap(Bitmap *);
 
+void LimitScreenUpdates(boolean);
+
 void InitVideoDisplay(void);
 void CloseVideoDisplay(void);
 void InitVideoBuffer(int, int, int, boolean);
index 8f8bf8f6d9f4fbfbcaa2b4ad125298832bfc969a..61feaae192fc68869015f868261d124ed2024150 100644 (file)
@@ -210,8 +210,44 @@ int maxWordLengthInString(char *text)
 
 void DrawInitTextExt(char *text, int ypos, int font_nr, boolean force)
 {
+#if 1
+#if 0
   static unsigned int progress_delay = 0;
   unsigned int progress_delay_value = 100;     /* (in milliseconds) */
+#endif
+
+  // LimitScreenUpdates(TRUE); // (ignore "force" for now)
+  // LimitScreenUpdates(!force);
+  LimitScreenUpdates(TRUE);
+
+  UPDATE_BUSY_STATE();
+
+#if 0
+  if (!force && !DelayReached(&progress_delay, progress_delay_value))
+    return;
+#endif
+
+  if (window != NULL &&
+      gfx.draw_init_text &&
+      gfx.num_fonts > 0 &&
+      gfx.font_bitmap_info[font_nr].bitmap != NULL)
+  {
+    int x = (video.width - getTextWidth(text, font_nr)) / 2;
+    int y = ypos;
+    int width = video.width;
+    int height = getFontHeight(font_nr);
+
+    ClearRectangle(drawto, 0, y, width, height);
+    DrawTextExt(drawto, x, y, text, font_nr, BLIT_OPAQUE);
+
+    BlitBitmap(drawto, window, 0, 0, video.width, video.height, 0, 0);
+  }
+#else
+  static unsigned int progress_delay = 0;
+  unsigned int progress_delay_value = 100;     /* (in milliseconds) */
+
+  // LimitScreenUpdates(TRUE); // (ignore "force" for now)
+  LimitScreenUpdates(!force);
 
   UPDATE_BUSY_STATE();
 
@@ -234,9 +270,16 @@ void DrawInitTextExt(char *text, int ypos, int font_nr, boolean force)
     /* this makes things significantly faster than directly drawing to window */
     BlitBitmap(drawto, window, 0, y, width, height, 0, y);
   }
+#endif
 }
 
 void DrawInitText(char *text, int ypos, int font_nr)
+{
+  // DrawInitTextExt(text, ypos, font_nr, TRUE);
+  DrawInitTextExt(text, ypos, font_nr, FALSE);
+}
+
+void DrawInitTextAlways(char *text, int ypos, int font_nr)
 {
   DrawInitTextExt(text, ypos, font_nr, TRUE);
 }
index 17d350a0210cef008e061780d64233dfe4d26e5f..e01dccdd89833f1372f00de39613982e3a33ae9c 100644 (file)
@@ -76,8 +76,10 @@ void getFontCharSource(int, char, Bitmap **, int *, int *);
 int maxWordLengthInString(char *);
 
 void DrawInitText(char *, int, int);
+void DrawInitTextAlways(char *, int, int);
 void DrawInitTextIfNeeded(char *, int, int);
 void DrawInitTextExt(char *, int, int, boolean);
+
 void DrawTextF(int, int, int, char *, ...);
 void DrawTextFCentered(int, int, char *, ...);
 void DrawTextS(int, int, int, char *);
index 7f694d98cede87b8a6dd47ce02fd04a8418466d3..6951099fa7ce61c31adc501dd8ee1aa09eae41fc 100644 (file)
@@ -1317,6 +1317,8 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading)
   static LevelDirTree *leveldir_last_valid = NULL;
   boolean levelset_has_changed = FALSE;
 
+  LimitScreenUpdates(FALSE);
+
   FadeSetLeaveScreen();
 
   /* do not fade out here -- function may continue and fade on editor screen */