--- hatari/src/falcon/hostscreen.c 2019/04/09 08:53:21 1.1.1.7 +++ hatari/src/falcon/hostscreen.c 2019/04/09 08:54:34 1.1.1.8 @@ -51,7 +51,8 @@ const char HostScreen_fileid[] = "Hatari /* TODO: put these hostscreen globals to some struct */ static Uint32 sdl_videoparams; -static int hs_width, hs_height, hs_width_req, hs_height_req, hs_bpp; +static SDL_Rect hs_rect; +static int hs_width_req, hs_height_req, hs_bpp; static bool doUpdate; // the HW surface is available -> the SDL need not to update the surface after ->pixel access static void HostScreen_remapPalette(void); @@ -94,12 +95,13 @@ void HostScreen_toggleFullScreen(void) HostScreen_setWindowSize(hs_width_req, hs_height_req, hs_bpp); /* force screen redraw */ - HostScreen_update1(true); + HostScreen_update1(NULL, true); } void HostScreen_setWindowSize(int width, int height, int bpp) { + const bool keep = ConfigureParams.Screen.bKeepResolution; int screenwidth, screenheight, maxw, maxh; int scalex, scaley, sbarheight; @@ -122,7 +124,7 @@ void HostScreen_setWindowSize(int width, height /= scaley; } - Resolution_GetLimits(&maxw, &maxh, &bpp, ConfigureParams.Screen.bKeepResolution); + Resolution_GetLimits(&maxw, &maxh, &bpp, keep); nScreenZoomX = nScreenZoomY = 1; if (ConfigureParams.Screen.bAspectCorrect) { @@ -171,7 +173,7 @@ void HostScreen_setWindowSize(int width, screenwidth = width; /* get resolution corresponding to these */ - Resolution_Search(&screenwidth, &screenheight, &bpp); + Resolution_Search(&screenwidth, &screenheight, &bpp, keep); /* re-calculate statusbar height for this resolution */ sbarheight = Statusbar_SetHeight(screenwidth, screenheight-sbarheight); @@ -180,8 +182,10 @@ void HostScreen_setWindowSize(int width, * in windowed mode because this uses screensize instead of using * the aspect scaled sizes directly, but it works better this way. */ - hs_width = screenwidth; - hs_height = screenheight - sbarheight; + hs_rect.x = 0; + hs_rect.y = 0; + hs_rect.w = screenwidth; + hs_rect.h = screenheight - sbarheight; if (sdlscrn && (!bpp || sdlscrn->format->BitsPerPixel == bpp) && sdlscrn->w == (signed)screenwidth && sdlscrn->h == (signed)screenheight && @@ -256,12 +260,20 @@ void HostScreen_setWindowSize(int width, } -void HostScreen_update1(bool forced) +void HostScreen_update1(SDL_Rect *extra, bool forced) { + SDL_Rect rects[2]; + int count = 1; + if ( !forced && !doUpdate ) // the HW surface is available return; - SDL_UpdateRect( sdlscrn, 0, 0, hs_width, hs_height ); + rects[0] = hs_rect; + if (extra) { + rects[1] = *extra; + count = 2; + } + SDL_UpdateRects(sdlscrn, count, rects); } @@ -277,12 +289,12 @@ Uint32 HostScreen_getPitch(void) Uint32 HostScreen_getWidth(void) { - return hs_width; + return hs_rect.w; } Uint32 HostScreen_getHeight(void) { - return hs_height; + return hs_rect.h; } Uint8 *HostScreen_getVideoramAddress(void) @@ -338,9 +350,14 @@ bool HostScreen_renderBegin(void) return true; } -void HostScreen_renderEnd(void) +/** + * Direct surface writes done, so unlock screen, + * check for statusbar updates and if there were such, + * return which area needs update. + */ +SDL_Rect* HostScreen_renderEnd(void) { if (SDL_MUSTLOCK(sdlscrn)) SDL_UnlockSurface(sdlscrn); - Statusbar_Update(sdlscrn); + return Statusbar_Update(sdlscrn, false); }