Refactored UpdateScreen for GUI

This commit is contained in:
Dimitris Panokostas 2017-02-22 14:30:04 +01:00
parent a950551682
commit a0be8a1d65
10 changed files with 25 additions and 59 deletions

View file

@ -251,12 +251,7 @@ static void CreateFilesysHardfileLoop()
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
UpdateScreen();
}
}

View file

@ -316,12 +316,7 @@ static void EditFilesysHardfileLoop()
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
UpdateScreen();
}
}

View file

@ -255,12 +255,7 @@ static void EditFilesysVirtualLoop(void)
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, NULL, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, NULL, NULL);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
UpdateScreen();
}
}

View file

@ -125,12 +125,7 @@ void InGameMessage(const char *msg)
// Finally we update the screen.
if (!drawn)
{
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
UpdateScreen();
}
drawn = true;
}

View file

@ -352,12 +352,7 @@ static void SelectFileLoop()
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
UpdateScreen();
if (!dialogCreated)
{

View file

@ -254,12 +254,7 @@ static void SelectFolderLoop()
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
UpdateScreen();
}
}

View file

@ -144,12 +144,7 @@ static void ShowMessageLoop()
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
UpdateScreen();
}
}

View file

@ -124,4 +124,6 @@ extern char *screenshot_filename;
extern int currentStateNum;
extern int delay_savestate_frame;
extern void UpdateScreen();
#endif // _GUI_HANDLING_H

View file

@ -139,6 +139,16 @@ void RegisterRefreshFunc(void (*func)())
refreshFuncAfterDraw = func;
}
void UpdateScreen()
{
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
}
namespace sdl
{
void gui_init()
@ -146,19 +156,16 @@ namespace sdl
//-------------------------------------------------
// Create new screen for GUI
//-------------------------------------------------
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother (linear scaling).
// make the scaled rendering look smoother (linear scaling).
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
gui_screen = SDL_CreateRGBSurface(0, GUI_WIDTH, GUI_HEIGHT, 32, 0, 0, 0, 0);
check_error_sdl(gui_screen == nullptr, "Unable to create a surface");
SDL_RenderSetLogicalSize(renderer, GUI_WIDTH, GUI_HEIGHT);
gui_texture = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
GUI_WIDTH,
GUI_HEIGHT);
gui_texture = SDL_CreateTextureFromSurface(renderer, gui_screen);
check_error_sdl(gui_texture == nullptr, "Unable to create texture");
SDL_ShowCursor(SDL_ENABLE);
@ -312,12 +319,7 @@ namespace sdl
uae_gui->draw();
// Finally we update the screen.
// Update the texture from the surface
SDL_UpdateTexture(gui_texture, nullptr, gui_screen->pixels, gui_screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, gui_texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
UpdateScreen();
if (refreshFuncAfterDraw != nullptr)
{

View file

@ -356,9 +356,6 @@ int create_configfilename(char* dest, char* basename, int fromDir)
const char* kickstarts_rom_names[] = {"kick12.rom\0", "kick13.rom\0", "kick20.rom\0", "kick31.rom\0", "aros-amiga-m68k-rom.bin\0"};
const char* extended_rom_names[] = {"\0", "\0", "\0", "\0", "aros-amiga-m68k-ext.bin\0"};
const char* kickstarts_names[] = {"KS ROM v1.2\0", "KS ROM v1.3\0", "KS ROM v2.05\0", "KS ROM v3.1\0", "\0"};
#ifdef ANDROID
const char *af_kickstarts_rom_names[] = { "amiga-os-120.rom\0", "amiga-os-130.rom\0", "amiga-os-204.rom\0", "amiga-os-310-a1200.rom\0" };
#endif
static bool CheckKickstart(struct uae_prefs* p)
{