From 235c648a6828bdd8201e1151b7e2815a4daf1201 Mon Sep 17 00:00:00 2001 From: that Date: Sun, 24 Jan 2016 21:59:00 +0100 Subject: gui: use XML-based page for splash screen instead of a static jpg For devices with an unusual aspect ratio, stretching a bitmap to the screen resolution is sub-optimal. So let's reuse our XML engine that allows assembling the splash screen from individual parts. The splash page is loaded from a separate XML file for quick loading. Change-Id: I2d3dad26e42fcefaf563dacdf0ffa61f209dada1 --- gui/gui.cpp | 117 ++-------------------- gui/pages.cpp | 9 +- gui/pages.hpp | 1 - gui/theme/landscape_hdpi/images/curtain.jpg | Bin 133833 -> 0 bytes gui/theme/landscape_hdpi/images/splashlogo.png | Bin 0 -> 15097 bytes gui/theme/landscape_hdpi/images/splashteamwin.png | Bin 0 -> 1680 bytes gui/theme/landscape_hdpi/splash.xml | 52 ++++++++++ gui/theme/landscape_mdpi/images/curtain.jpg | Bin 39268 -> 0 bytes gui/theme/landscape_mdpi/images/splashlogo.png | Bin 0 -> 6239 bytes gui/theme/landscape_mdpi/images/splashteamwin.png | Bin 0 -> 1547 bytes gui/theme/landscape_mdpi/splash.xml | 52 ++++++++++ gui/theme/portrait_hdpi/images/curtain.jpg | Bin 52988 -> 0 bytes gui/theme/portrait_hdpi/images/splashlogo.png | Bin 0 -> 15097 bytes gui/theme/portrait_hdpi/images/splashteamwin.png | Bin 0 -> 1680 bytes gui/theme/portrait_hdpi/splash.xml | 52 ++++++++++ gui/theme/portrait_mdpi/images/curtain.jpg | Bin 43476 -> 0 bytes gui/theme/portrait_mdpi/images/splashlogo.png | Bin 0 -> 6239 bytes gui/theme/portrait_mdpi/images/splashteamwin.png | Bin 0 -> 1547 bytes gui/theme/portrait_mdpi/splash.xml | 52 ++++++++++ gui/theme/watch_mdpi/images/curtain.jpg | Bin 28427 -> 0 bytes gui/theme/watch_mdpi/images/splashlogo.png | Bin 0 -> 5597 bytes gui/theme/watch_mdpi/images/splashteamwin.png | Bin 0 -> 983 bytes gui/theme/watch_mdpi/splash.xml | 52 ++++++++++ 23 files changed, 270 insertions(+), 117 deletions(-) delete mode 100644 gui/theme/landscape_hdpi/images/curtain.jpg create mode 100755 gui/theme/landscape_hdpi/images/splashlogo.png create mode 100755 gui/theme/landscape_hdpi/images/splashteamwin.png create mode 100755 gui/theme/landscape_hdpi/splash.xml delete mode 100644 gui/theme/landscape_mdpi/images/curtain.jpg create mode 100755 gui/theme/landscape_mdpi/images/splashlogo.png create mode 100755 gui/theme/landscape_mdpi/images/splashteamwin.png create mode 100755 gui/theme/landscape_mdpi/splash.xml delete mode 100644 gui/theme/portrait_hdpi/images/curtain.jpg create mode 100755 gui/theme/portrait_hdpi/images/splashlogo.png create mode 100755 gui/theme/portrait_hdpi/images/splashteamwin.png create mode 100755 gui/theme/portrait_hdpi/splash.xml delete mode 100644 gui/theme/portrait_mdpi/images/curtain.jpg create mode 100755 gui/theme/portrait_mdpi/images/splashlogo.png create mode 100755 gui/theme/portrait_mdpi/images/splashteamwin.png create mode 100755 gui/theme/portrait_mdpi/splash.xml delete mode 100644 gui/theme/watch_mdpi/images/curtain.jpg create mode 100755 gui/theme/watch_mdpi/images/splashlogo.png create mode 100755 gui/theme/watch_mdpi/images/splashteamwin.png create mode 100755 gui/theme/watch_mdpi/splash.xml diff --git a/gui/gui.cpp b/gui/gui.cpp index d99764aea..7cf21b0a0 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -62,15 +62,11 @@ extern "C" #define LOGEVENT(...) do {} while (0) #endif -const static int CURTAIN_FADE = 32; - using namespace rapidxml; // Global values -static gr_surface gCurtain = NULL; static int gGuiInitialized = 0; static TWAtomicInt gForceRender; -const int gNoAnimation = 1; blanktimer blankTimer; int ors_read_fd = -1; static FILE* orsout = NULL; @@ -107,80 +103,6 @@ void rapidxml::parse_error_handler(const char *what, void *where) //abort(); } -static void curtainSet() -{ - gr_color(0, 0, 0, 255); - gr_fill(0, 0, gr_fb_width(), gr_fb_height()); - gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), gr_get_height(gCurtain), TW_X_OFFSET, TW_Y_OFFSET); - gr_flip(); -} - -static void curtainRaise(gr_surface surface) -{ - int sy = 0; - int h = gr_get_height(gCurtain) - 1; - int w = gr_get_width(gCurtain); - int fy = 1; - - int msw = gr_get_width(surface); - int msh = gr_get_height(surface); - int CURTAIN_RATE = msh / 30; - - if (gNoAnimation == 0) - { - for (; h > 0; h -= CURTAIN_RATE, sy += CURTAIN_RATE, fy += CURTAIN_RATE) - { - gr_blit(surface, 0, 0, msw, msh, 0, 0); - gr_blit(gCurtain, 0, sy, w, h, 0, 0); - gr_flip(); - } - } - gr_blit(surface, 0, 0, msw, msh, 0, 0); - flip(); -} - -void curtainClose() -{ -#if 0 - int w = gr_get_width(gCurtain); - int h = 1; - int sy = gr_get_height(gCurtain) - 1; - int fbh = gr_fb_height(); - int CURTAIN_RATE = fbh / 30; - - if (gNoAnimation == 0) - { - for (; h < fbh; h += CURTAIN_RATE, sy -= CURTAIN_RATE) - { - gr_blit(gCurtain, 0, sy, w, h, 0, 0); - gr_flip(); - } - gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), - gr_get_height(gCurtain), 0, 0); - gr_flip(); - - if (gRecorder != -1) - close(gRecorder); - - int fade; - for (fade = 16; fade < 255; fade += CURTAIN_FADE) - { - gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), - gr_get_height(gCurtain), 0, 0); - gr_color(0, 0, 0, fade); - gr_fill(0, 0, gr_fb_width(), gr_fb_height()); - gr_flip(); - } - gr_color(0, 0, 0, 255); - gr_fill(0, 0, gr_fb_width(), gr_fb_height()); - gr_flip(); - } -#else - gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), gr_get_height(gCurtain), 0, 0); - gr_flip(); -#endif -} - class InputHandler { public: @@ -618,17 +540,6 @@ static int runPages(const char *page_name, const int stop_on_page_done) gui_changePage(page_name); } - // Raise the curtain - if (gCurtain != NULL) - { - gr_surface surface; - - PageManager::Render(); - gr_get_surface(&surface); - curtainRaise(surface); - gr_free_surface(surface); - } - gGuiRunning = 1; DataManager::SetValue("tw_loaded", 1); @@ -822,30 +733,18 @@ std::string gui_lookup(const std::string& resource_name, const std::string& defa extern "C" int gui_init(void) { gr_init(); - std::string curtain_path = TWRES "images/curtain.jpg"; - gr_surface source_Surface = NULL; - if (res_create_surface(curtain_path.c_str(), &source_Surface)) - { - printf("Unable to locate '%s'\nDid you set a TW_THEME in your config files?\n", curtain_path.c_str()); - return -1; + // load and show splash screen + if (PageManager::LoadPackage("splash", TWRES "splash.xml", "splash")) { + LOGERR("Failed to load splash screen XML.\n"); } - if (gr_get_width(source_Surface) != (unsigned)gr_fb_width() || gr_get_height(source_Surface) != (unsigned)gr_fb_height()) { - // We need to scale the curtain to fit the screen - float scale_w = (float)gr_fb_width() / (float)gr_get_width(source_Surface); - float scale_h = (float)gr_fb_height() / (float)gr_get_height(source_Surface); - if (res_scale_surface(source_Surface, &gCurtain, scale_w, scale_h)) { - LOGINFO("Failed to scale curtain\n"); - gCurtain = source_Surface; - } else { - LOGINFO("Scaling the curtain width %fx and height %fx\n", scale_w, scale_h); - } - } else { - gCurtain = source_Surface; + else { + PageManager::SelectPackage("splash"); + PageManager::Render(); + flip(); + PageManager::ReleasePackage("splash"); } - curtainSet(); - ev_init(); return 0; } diff --git a/gui/pages.cpp b/gui/pages.cpp index def262998..c45566232 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -64,7 +64,6 @@ extern std::vector gConsoleColor; std::map PageManager::mPageSets; PageSet* PageManager::mCurrentSet; -PageSet* PageManager::mBaseSet = NULL; MouseCursor *PageManager::mMouseCursor = NULL; HardwareKeyboard *PageManager::mHardwareKeyboard = NULL; bool PageManager::mReloadTheme = false; @@ -1421,10 +1420,6 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string LOGERR("Package %s failed to load.\n", name.c_str()); } - // The first successful package we loaded is the base - if (mBaseSet == NULL) - mBaseSet = mCurrentSet; - mCurrentSet = pageSet; if (pZip) { @@ -1500,8 +1495,6 @@ int PageManager::ReloadPackage(std::string name, std::string package) } if (mCurrentSet == set) SelectPackage(name); - if (mBaseSet == set) - mBaseSet = mCurrentSet; delete set; GUIConsole::Translate_Now(); return 0; @@ -1518,6 +1511,8 @@ void PageManager::ReleasePackage(std::string name) PageSet* set = (*iter).second; mPageSets.erase(iter); delete set; + if (set == mCurrentSet) + mCurrentSet = NULL; return; } diff --git a/gui/pages.hpp b/gui/pages.hpp index bb521c1d2..cf1afa1e9 100644 --- a/gui/pages.hpp +++ b/gui/pages.hpp @@ -178,7 +178,6 @@ protected: protected: static std::map mPageSets; static PageSet* mCurrentSet; - static PageSet* mBaseSet; static MouseCursor *mMouseCursor; static HardwareKeyboard *mHardwareKeyboard; static bool mReloadTheme; diff --git a/gui/theme/landscape_hdpi/images/curtain.jpg b/gui/theme/landscape_hdpi/images/curtain.jpg deleted file mode 100644 index 51ea6a571..000000000 Binary files a/gui/theme/landscape_hdpi/images/curtain.jpg and /dev/null differ diff --git a/gui/theme/landscape_hdpi/images/splashlogo.png b/gui/theme/landscape_hdpi/images/splashlogo.png new file mode 100755 index 000000000..337a7b6de Binary files /dev/null and b/gui/theme/landscape_hdpi/images/splashlogo.png differ diff --git a/gui/theme/landscape_hdpi/images/splashteamwin.png b/gui/theme/landscape_hdpi/images/splashteamwin.png new file mode 100755 index 000000000..f44a8febc Binary files /dev/null and b/gui/theme/landscape_hdpi/images/splashteamwin.png differ diff --git a/gui/theme/landscape_hdpi/splash.xml b/gui/theme/landscape_hdpi/splash.xml new file mode 100755 index 000000000..1a9fd5340 --- /dev/null +++ b/gui/theme/landscape_hdpi/splash.xml @@ -0,0 +1,52 @@ + + +
+ + TeamWin + TWRP + Default basic theme + preview.jpg + 1 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Recovery Project %tw_version% + + + +
+ diff --git a/gui/theme/landscape_mdpi/images/curtain.jpg b/gui/theme/landscape_mdpi/images/curtain.jpg deleted file mode 100644 index f79ab92b5..000000000 Binary files a/gui/theme/landscape_mdpi/images/curtain.jpg and /dev/null differ diff --git a/gui/theme/landscape_mdpi/images/splashlogo.png b/gui/theme/landscape_mdpi/images/splashlogo.png new file mode 100755 index 000000000..4b29425e8 Binary files /dev/null and b/gui/theme/landscape_mdpi/images/splashlogo.png differ diff --git a/gui/theme/landscape_mdpi/images/splashteamwin.png b/gui/theme/landscape_mdpi/images/splashteamwin.png new file mode 100755 index 000000000..125501fcb Binary files /dev/null and b/gui/theme/landscape_mdpi/images/splashteamwin.png differ diff --git a/gui/theme/landscape_mdpi/splash.xml b/gui/theme/landscape_mdpi/splash.xml new file mode 100755 index 000000000..34f832578 --- /dev/null +++ b/gui/theme/landscape_mdpi/splash.xml @@ -0,0 +1,52 @@ + + +
+ + TeamWin + TWRP + Default basic theme + preview.jpg + 1 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Recovery Project %tw_version% + + + +
+ diff --git a/gui/theme/portrait_hdpi/images/curtain.jpg b/gui/theme/portrait_hdpi/images/curtain.jpg deleted file mode 100644 index fd0ea31ef..000000000 Binary files a/gui/theme/portrait_hdpi/images/curtain.jpg and /dev/null differ diff --git a/gui/theme/portrait_hdpi/images/splashlogo.png b/gui/theme/portrait_hdpi/images/splashlogo.png new file mode 100755 index 000000000..337a7b6de Binary files /dev/null and b/gui/theme/portrait_hdpi/images/splashlogo.png differ diff --git a/gui/theme/portrait_hdpi/images/splashteamwin.png b/gui/theme/portrait_hdpi/images/splashteamwin.png new file mode 100755 index 000000000..f44a8febc Binary files /dev/null and b/gui/theme/portrait_hdpi/images/splashteamwin.png differ diff --git a/gui/theme/portrait_hdpi/splash.xml b/gui/theme/portrait_hdpi/splash.xml new file mode 100755 index 000000000..964b2af98 --- /dev/null +++ b/gui/theme/portrait_hdpi/splash.xml @@ -0,0 +1,52 @@ + + +
+ + TeamWin + TWRP + Default basic theme + preview.jpg + 1 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Recovery Project %tw_version% + + + +
+ diff --git a/gui/theme/portrait_mdpi/images/curtain.jpg b/gui/theme/portrait_mdpi/images/curtain.jpg deleted file mode 100644 index 680b023b6..000000000 Binary files a/gui/theme/portrait_mdpi/images/curtain.jpg and /dev/null differ diff --git a/gui/theme/portrait_mdpi/images/splashlogo.png b/gui/theme/portrait_mdpi/images/splashlogo.png new file mode 100755 index 000000000..4b29425e8 Binary files /dev/null and b/gui/theme/portrait_mdpi/images/splashlogo.png differ diff --git a/gui/theme/portrait_mdpi/images/splashteamwin.png b/gui/theme/portrait_mdpi/images/splashteamwin.png new file mode 100755 index 000000000..125501fcb Binary files /dev/null and b/gui/theme/portrait_mdpi/images/splashteamwin.png differ diff --git a/gui/theme/portrait_mdpi/splash.xml b/gui/theme/portrait_mdpi/splash.xml new file mode 100755 index 000000000..31f793380 --- /dev/null +++ b/gui/theme/portrait_mdpi/splash.xml @@ -0,0 +1,52 @@ + + +
+ + TeamWin + TWRP + Default basic theme + preview.jpg + 1 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Recovery Project %tw_version% + + + +
+ diff --git a/gui/theme/watch_mdpi/images/curtain.jpg b/gui/theme/watch_mdpi/images/curtain.jpg deleted file mode 100644 index 1d1d49e87..000000000 Binary files a/gui/theme/watch_mdpi/images/curtain.jpg and /dev/null differ diff --git a/gui/theme/watch_mdpi/images/splashlogo.png b/gui/theme/watch_mdpi/images/splashlogo.png new file mode 100755 index 000000000..757c74058 Binary files /dev/null and b/gui/theme/watch_mdpi/images/splashlogo.png differ diff --git a/gui/theme/watch_mdpi/images/splashteamwin.png b/gui/theme/watch_mdpi/images/splashteamwin.png new file mode 100755 index 000000000..94546f8e6 Binary files /dev/null and b/gui/theme/watch_mdpi/images/splashteamwin.png differ diff --git a/gui/theme/watch_mdpi/splash.xml b/gui/theme/watch_mdpi/splash.xml new file mode 100755 index 000000000..81bef4513 --- /dev/null +++ b/gui/theme/watch_mdpi/splash.xml @@ -0,0 +1,52 @@ + + +
+ + TeamWin + TWRP + Default basic theme + preview.jpg + 1 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Recovery Project %tw_version% + + + +
+ -- cgit v1.2.3