From bd813831b0ca64fb63a37fccb1960a4058d89223 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 17 Dec 2014 13:01:13 +0000 Subject: [PATCH] Wii: Work around a performance regression caused by r4080. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4819 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/sdlayer.c | 13 +++++++++++++ polymer/eduke32/build/src/sdlayer12.c | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index af87a2fdb..bf50ae537 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -40,6 +40,9 @@ #ifdef __ANDROID__ #include #endif +#if defined GEKKO +# define SDL_DISABLE_8BIT_BUFFER +#endif #if !defined STARTUP_SETUP_WINDOW int32_t startwin_open(void) { return 0; } @@ -66,7 +69,11 @@ char quitevent=0, appactive=1, novideo=0; // video static SDL_Surface *sdl_surface/*=NULL*/; +#if !defined SDL_DISABLE_8BIT_BUFFER static SDL_Surface *sdl_buffersurface=NULL; +#else +# define sdl_buffersurface sdl_surface +#endif #if SDL_MAJOR_VERSION==2 static SDL_Palette *sdl_palptr=NULL; @@ -1139,10 +1146,12 @@ static SDL_Color sdlayer_pal[256]; static void destroy_window_resources() { +#if !defined SDL_DISABLE_8BIT_BUFFER if (sdl_buffersurface) SDL_FreeSurface(sdl_buffersurface); sdl_buffersurface = NULL; +#endif /* We should NOT destroy the window surface. This is done automatically when SDL_DestroyWindow or SDL_SetVideoMode is called. */ @@ -1455,10 +1464,12 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) SDL2_VIDEO_ERR("SDL_GetWindowSurface"); } +#if !defined SDL_DISABLE_8BIT_BUFFER sdl_buffersurface = SDL_CreateRGBSurface(0, x, y, c, 0, 0, 0, 0); if (!sdl_buffersurface) SDL2_VIDEO_ERR("SDL_CreateRGBSurface"); +#endif if (!sdl_palptr) sdl_palptr = SDL_AllocPalette(256); @@ -1574,7 +1585,9 @@ void showframe(int32_t w) needpalupdate = 0; } +#if !defined SDL_DISABLE_8BIT_BUFFER SDL_BlitSurface(sdl_buffersurface, NULL, sdl_surface, NULL); +#endif if (sdl_renderer && sdl_texture) { diff --git a/polymer/eduke32/build/src/sdlayer12.c b/polymer/eduke32/build/src/sdlayer12.c index 5b3577626..dbba20baa 100644 --- a/polymer/eduke32/build/src/sdlayer12.c +++ b/polymer/eduke32/build/src/sdlayer12.c @@ -267,8 +267,12 @@ void getvalidmodes(void) pf.BitsPerPixel = cdepths[j]; pf.BytesPerPixel = cdepths[j] >> 3; +#if !defined SDL_DISABLE_8BIT_BUFFER // We convert paletted contents to non-paletted modes = SDL_ListModes((cdepths[j] == 8) ? NULL : &pf, SURFACE_FLAGS | SDL_FULLSCREEN); +#else + modes = SDL_ListModes(&pf, SURFACE_FLAGS | SDL_FULLSCREEN); +#endif if (modes == (SDL_Rect **)0) { @@ -409,19 +413,25 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) else #endif // defined USE_OPENGL { +#if !defined SDL_DISABLE_8BIT_BUFFER // We convert paletted contents to non-paletted sdl_surface = SDL_SetVideoMode(x, y, 0, SURFACE_FLAGS | ((fs & 1) ? SDL_FULLSCREEN : 0)); +#else + sdl_surface = SDL_SetVideoMode(x, y, c, SURFACE_FLAGS | ((fs & 1) ? SDL_FULLSCREEN : 0)); +#endif if (!sdl_surface) { initprintf("Unable to set video mode!\n"); return -1; } +#if !defined SDL_DISABLE_8BIT_BUFFER sdl_buffersurface = SDL_CreateRGBSurface(SURFACE_FLAGS, x, y, c, 0, 0, 0, 0); if (!sdl_buffersurface) { initprintf("Unable to set video mode: SDL_CreateRGBSurface failed: %s\n", SDL_GetError()); return -1; } +#endif } setvideomode_sdlcommonpost(x, y, c, fs, regrab); @@ -462,7 +472,9 @@ void showframe(int32_t w) needpalupdate = 0; } +#if !defined SDL_DISABLE_8BIT_BUFFER SDL_BlitSurface(sdl_buffersurface, NULL, sdl_surface, NULL); +#endif SDL_Flip(sdl_surface); }