From 80a7a4642be31db7ecd5eaa9e62b78deaa461146 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Fri, 30 Aug 2013 16:59:06 -0700 Subject: screen_ui: Initialize text buffer Zero initialize the text buffer to make recovery not render garbage when showing the menu or messages. Change-Id: I0dd0d357757f6b0fd52ad3b3617d42bb1b835245 --- screen_ui.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 93e260936..b53ab1158 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -86,6 +86,8 @@ ScreenRecoveryUI::ScreenRecoveryUI() : for (int i = 0; i < 5; i++) backgroundIcon[i] = NULL; + memset(text, 0, sizeof(text)); + pthread_mutex_init(&updateMutex, NULL); self = this; } -- cgit v1.2.3 From 9b8ae8038be65c2ec236bc04590716fbcd5363f6 Mon Sep 17 00:00:00 2001 From: Alistair Strachan Date: Wed, 17 Jul 2013 10:34:36 -0700 Subject: Fix rare crash seen when dereferencing backgroundIcon[NONE]. Because backgroundIcon[] is not initialized by the ScreenRecoveryUI constructor, it should be initialized explicitly to NULL in Init(). If it is not initialized, ScreenRecoveryUI::SetBackground() can fail for the NONE icon because the NULL test can fail and junk will be dereferenced. Change-Id: I4e3738d2e241ed90df43c984fb41e0072933f50a --- screen_ui.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 8376341c3..be7abca1d 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -376,6 +376,7 @@ void ScreenRecoveryUI::Init() text_cols = gr_fb_width() / char_width; if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; + backgroundIcon[NONE] = NULL; LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]); backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; LoadBitmap("icon_error", &backgroundIcon[ERROR]); -- cgit v1.2.3 From c87bab101893e8322b49d7c8600e3367b20ab50a Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 25 Nov 2013 13:53:25 -0800 Subject: add the functions for multi-stage packages to updater In order to support multi-stage recovery packages, we add the set_stage() and get_stage() functions, which store a short string somewhere it can be accessed across invocations of recovery. We also add reboot_now() which updater can invoke to immediately reboot the device, without doing normal recovery cleanup. (It can also choose whether to boot off the boot or recovery partition.) If the stage string is of the form "#/#", recovery's UI will be augmented with a simple indicator of what stage you're in, so it doesn't look like a reboot loop. Change-Id: I62f7ff0bc802b549c9bcf3cc154a6bad99f94603 --- screen_ui.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 8376341c3..27d0a245c 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -81,7 +81,9 @@ ScreenRecoveryUI::ScreenRecoveryUI() : install_overlay_offset_x(13), install_overlay_offset_y(190), overlay_offset_x(-1), - overlay_offset_y(-1) { + overlay_offset_y(-1), + stage(-1), + max_stage(-1) { for (int i = 0; i < 5; i++) backgroundIcon[i] = NULL; @@ -120,14 +122,28 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) int iconHeight = gr_get_height(surface); int textWidth = gr_get_width(text_surface); int textHeight = gr_get_height(text_surface); + int stageHeight = gr_get_height(stageMarkerEmpty); + + int sh = (max_stage >= 0) ? stageHeight : 0; int iconX = (gr_fb_width() - iconWidth) / 2; - int iconY = (gr_fb_height() - (iconHeight+textHeight+40)) / 2; + int iconY = (gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2; int textX = (gr_fb_width() - textWidth) / 2; - int textY = ((gr_fb_height() - (iconHeight+textHeight+40)) / 2) + iconHeight + 40; + int textY = ((gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2) + iconHeight + 40; gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); + if (stageHeight > 0) { + int sw = gr_get_width(stageMarkerEmpty); + int x = (gr_fb_width() - max_stage * gr_get_width(stageMarkerEmpty)) / 2; + int y = iconY + iconHeight + 20; + for (int i = 0; i < max_stage; ++i) { + gr_blit((i < stage) ? stageMarkerFill : stageMarkerEmpty, + 0, 0, sw, stageHeight, x, y); + x += sw; + } + } + if (icon == INSTALLING_UPDATE || icon == ERASING) { draw_install_overlay_locked(installingFrame); } @@ -383,6 +399,8 @@ void ScreenRecoveryUI::Init() LoadBitmap("progress_empty", &progressBarEmpty); LoadBitmap("progress_fill", &progressBarFill); + LoadBitmap("stage_empty", &stageMarkerEmpty); + LoadBitmap("stage_fill", &stageMarkerFill); LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]); LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]); @@ -453,7 +471,10 @@ void ScreenRecoveryUI::SetBackground(Icon icon) gr_surface text = backgroundText[icon]; overlay_offset_x = install_overlay_offset_x + (gr_fb_width() - gr_get_width(bg)) / 2; overlay_offset_y = install_overlay_offset_y + - (gr_fb_height() - (gr_get_height(bg) + gr_get_height(text) + 40)) / 2; + (gr_fb_height() - (gr_get_height(bg) + + gr_get_height(text) + + 40 + + ((max_stage >= 0) ? gr_get_height(stageMarkerEmpty) : 0))) / 2; } currentIcon = icon; @@ -505,6 +526,13 @@ void ScreenRecoveryUI::SetProgress(float fraction) pthread_mutex_unlock(&updateMutex); } +void ScreenRecoveryUI::SetStage(int current, int max) { + pthread_mutex_lock(&updateMutex); + stage = current; + max_stage = max; + pthread_mutex_unlock(&updateMutex); +} + void ScreenRecoveryUI::Print(const char *fmt, ...) { char buf[256]; -- cgit v1.2.3 From eac881c952fc6be0beeb5f719e3a70e651f3610e Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 7 Mar 2014 09:21:25 -0800 Subject: change how recovery animation is implemented Instead of one 'base' installing image and a number of overlay images that are drawn on top of it, we represent the installing animation with one PNG that contains all the animation frames, interlaced by row. The PNG is expected to have a text chunk with the keyword 'Frames' and a value that's the number of frames (as an ascii string). This representation provides better compression, removes the need to subclass ScreenRecoveryUI just to change the position of the overlay or number of frames, and doesn't require gr_blit() to support an alpha channel. We also remove the 'indeterminate' progress bar used when wiping data and/or cache. The main animation serves the same purpose (showing that the device is still alive); the spinning progress bar has been redundant for a while. This changes the default recovery animation to include the antenna-wiggling and gear-turning that's used in the Nexus 5 recovery animation. Change-Id: I51930a76035ac09969a25472f4e572b289418729 --- screen_ui.cpp | 109 ++++++++++------------------------------------------------ 1 file changed, 18 insertions(+), 91 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index fd1a6c7fa..a72da58a6 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -69,19 +69,8 @@ ScreenRecoveryUI::ScreenRecoveryUI() : menu_top(0), menu_items(0), menu_sel(0), - - // These values are correct for the default image resources - // provided with the android platform. Devices which use - // different resources should have a subclass of ScreenRecoveryUI - // that overrides Init() to set these values appropriately and - // then call the superclass Init(). animation_fps(20), - indeterminate_frames(6), - installing_frames(7), - install_overlay_offset_x(13), - install_overlay_offset_y(190), - overlay_offset_x(-1), - overlay_offset_y(-1), + installing_frames(-1), stage(-1), max_stage(-1) { @@ -92,20 +81,6 @@ ScreenRecoveryUI::ScreenRecoveryUI() : self = this; } -// Draw the given frame over the installation overlay animation. The -// background is not cleared or draw with the base icon first; we -// assume that the frame already contains some other frame of the -// animation. Does nothing if no overlay animation is defined. -// Should only be called with updateMutex locked. -void ScreenRecoveryUI::draw_install_overlay_locked(int frame) { - if (installationOverlay == NULL || overlay_offset_x < 0) return; - gr_surface surface = installationOverlay[frame]; - int iconWidth = gr_get_width(surface); - int iconHeight = gr_get_height(surface); - gr_blit(surface, 0, 0, iconWidth, iconHeight, - overlay_offset_x, overlay_offset_y); -} - // Clear the screen and draw the currently selected background icon (if any). // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_background_locked(Icon icon) @@ -116,6 +91,9 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) if (icon) { gr_surface surface = backgroundIcon[icon]; + if (icon == INSTALLING_UPDATE || icon == ERASING) { + surface = installation[installingFrame]; + } gr_surface text_surface = backgroundText[icon]; int iconWidth = gr_get_width(surface); @@ -126,8 +104,8 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) int sh = (max_stage >= 0) ? stageHeight : 0; - int iconX = (gr_fb_width() - iconWidth) / 2; - int iconY = (gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2; + iconX = (gr_fb_width() - iconWidth) / 2; + iconY = (gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2; int textX = (gr_fb_width() - textWidth) / 2; int textY = ((gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2) + iconHeight + 40; @@ -144,10 +122,6 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) } } - if (icon == INSTALLING_UPDATE || icon == ERASING) { - draw_install_overlay_locked(installingFrame); - } - gr_color(255, 255, 255, 255); gr_texticon(textX, textY, text_surface); } @@ -160,7 +134,8 @@ void ScreenRecoveryUI::draw_progress_locked() if (currentIcon == ERROR) return; if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { - draw_install_overlay_locked(installingFrame); + gr_surface icon = installation[installingFrame]; + gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY); } if (progressBarType != EMPTY) { @@ -197,18 +172,6 @@ void ScreenRecoveryUI::draw_progress_locked() } } } - - if (progressBarType == INDETERMINATE) { - static int frame = 0; - gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy); - // in RTL locales, we run the animation backwards, which - // makes the spinner spin the other way. - if (rtl_locale) { - frame = (frame + indeterminate_frames - 1) % indeterminate_frames; - } else { - frame = (frame + 1) % indeterminate_frames; - } - } } } @@ -335,12 +298,6 @@ void ScreenRecoveryUI::progress_loop() { redraw = 1; } - // update the progress bar animation, if active - // skip this if we have a text overlay (too expensive to update) - if (progressBarType == INDETERMINATE && !show_text) { - redraw = 1; - } - // move the progress bar forward on timed intervals, if configured int duration = progressScopeDuration; if (progressBarType == DETERMINATE && duration > 0) { @@ -371,6 +328,13 @@ void ScreenRecoveryUI::LoadBitmap(const char* filename, gr_surface* surface) { } } +void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, gr_surface** surface) { + int result = res_create_multi_surface(filename, frames, surface); + if (result < 0) { + LOGE("missing bitmap %s\n(Code %d)\n", filename, result); + } +} + void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, gr_surface* surface) { int result = res_create_localized_surface(filename, surface); if (result < 0) { @@ -393,7 +357,8 @@ void ScreenRecoveryUI::Init() if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; backgroundIcon[NONE] = NULL; - LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]); + LoadBitmapArray("icon_installing", &installing_frames, &installation); + backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : NULL; backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; LoadBitmap("icon_error", &backgroundIcon[ERROR]); backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; @@ -408,31 +373,6 @@ void ScreenRecoveryUI::Init() LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]); LoadLocalizedBitmap("error_text", &backgroundText[ERROR]); - int i; - - progressBarIndeterminate = (gr_surface*)malloc(indeterminate_frames * - sizeof(gr_surface)); - for (i = 0; i < indeterminate_frames; ++i) { - char filename[40]; - // "indeterminate01.png", "indeterminate02.png", ... - sprintf(filename, "indeterminate%02d", i+1); - LoadBitmap(filename, progressBarIndeterminate+i); - } - - if (installing_frames > 0) { - installationOverlay = (gr_surface*)malloc(installing_frames * - sizeof(gr_surface)); - for (i = 0; i < installing_frames; ++i) { - char filename[40]; - // "icon_installing_overlay01.png", - // "icon_installing_overlay02.png", ... - sprintf(filename, "icon_installing_overlay%02d", i+1); - LoadBitmap(filename, installationOverlay+i); - } - } else { - installationOverlay = NULL; - } - pthread_create(&progress_t, NULL, progress_thread, NULL); RecoveryUI::Init(); @@ -465,19 +405,6 @@ void ScreenRecoveryUI::SetBackground(Icon icon) { pthread_mutex_lock(&updateMutex); - // Adjust the offset to account for the positioning of the - // base image on the screen. - if (backgroundIcon[icon] != NULL) { - gr_surface bg = backgroundIcon[icon]; - gr_surface text = backgroundText[icon]; - overlay_offset_x = install_overlay_offset_x + (gr_fb_width() - gr_get_width(bg)) / 2; - overlay_offset_y = install_overlay_offset_y + - (gr_fb_height() - (gr_get_height(bg) + - gr_get_height(text) + - 40 + - ((max_stage >= 0) ? gr_get_height(stageMarkerEmpty) : 0))) / 2; - } - currentIcon = icon; update_screen_locked(); @@ -517,7 +444,7 @@ void ScreenRecoveryUI::SetProgress(float fraction) if (fraction > 1.0) fraction = 1.0; if (progressBarType == DETERMINATE && fraction > progress) { // Skip updates that aren't visibly different. - int width = gr_get_width(progressBarIndeterminate[0]); + int width = gr_get_width(progressBarEmpty); float scale = width * progressScopeSize; if ((int) (progress * scale) != (int) (fraction * scale)) { progress = fraction; -- cgit v1.2.3 From 39cf417e17011a72dd39acfe4cc8c90af26bdbaf Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 6 Mar 2014 16:16:05 -0800 Subject: remove pixelflinger from recovery Recovery now draws directly to the framebuffer by rolling its own graphics code, rather than depending on libpixelflinger. The recovery UI is modified slightly to eliminate operations that are slow with the software implementation: when the text display / menu is turned on, it now appears on a black background instead of a dimmed version of the recovery icon. There's probably substantial room for optimization of the graphics operations. Bug: 12131110 Change-Id: Iab6520e0a7aaec39e2ce39377c10aef82ae0c595 --- screen_ui.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index a72da58a6..c87c00ce5 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -87,7 +87,7 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) { pagesIdentical = false; gr_color(0, 0, 0, 255); - gr_fill(0, 0, gr_fb_width(), gr_fb_height()); + gr_clear(); if (icon) { gr_surface surface = backgroundIcon[icon]; @@ -203,12 +203,12 @@ void ScreenRecoveryUI::SetColor(UIElement e) { // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_screen_locked() { - draw_background_locked(currentIcon); - draw_progress_locked(); - - if (show_text) { - SetColor(TEXT_FILL); - gr_fill(0, 0, gr_fb_width(), gr_fb_height()); + if (!show_text) { + draw_background_locked(currentIcon); + draw_progress_locked(); + } else { + gr_color(0, 0, 0, 255); + gr_clear(); int y = 0; int i = 0; -- cgit v1.2.3 From 469954fe3d7c3d729e500512ab911a037b90cc77 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 7 Mar 2014 09:21:25 -0800 Subject: change how recovery animation is implemented Instead of one 'base' installing image and a number of overlay images that are drawn on top of it, we represent the installing animation with one PNG that contains all the animation frames, interlaced by row. The PNG is expected to have a text chunk with the keyword 'Frames' and a value that's the number of frames (as an ascii string). This representation provides better compression, removes the need to subclass ScreenRecoveryUI just to change the position of the overlay or number of frames, and doesn't require gr_blit() to support an alpha channel. We also remove the 'indeterminate' progress bar used when wiping data and/or cache. The main animation serves the same purpose (showing that the device is still alive); the spinning progress bar has been redundant for a while. This changes the default recovery animation to include the antenna-wiggling and gear-turning that's used in the Nexus 5 recovery animation. Change-Id: I51930a76035ac09969a25472f4e572b289418729 Conflicts: screen_ui.cpp screen_ui.h --- screen_ui.cpp | 107 +++++++++++----------------------------------------------- 1 file changed, 19 insertions(+), 88 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 8376341c3..38b21f84c 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -69,20 +69,8 @@ ScreenRecoveryUI::ScreenRecoveryUI() : menu_top(0), menu_items(0), menu_sel(0), - - // These values are correct for the default image resources - // provided with the android platform. Devices which use - // different resources should have a subclass of ScreenRecoveryUI - // that overrides Init() to set these values appropriately and - // then call the superclass Init(). animation_fps(20), - indeterminate_frames(6), - installing_frames(7), - install_overlay_offset_x(13), - install_overlay_offset_y(190), - overlay_offset_x(-1), - overlay_offset_y(-1) { - + installing_frames(-1) { for (int i = 0; i < 5; i++) backgroundIcon[i] = NULL; @@ -90,20 +78,6 @@ ScreenRecoveryUI::ScreenRecoveryUI() : self = this; } -// Draw the given frame over the installation overlay animation. The -// background is not cleared or draw with the base icon first; we -// assume that the frame already contains some other frame of the -// animation. Does nothing if no overlay animation is defined. -// Should only be called with updateMutex locked. -void ScreenRecoveryUI::draw_install_overlay_locked(int frame) { - if (installationOverlay == NULL || overlay_offset_x < 0) return; - gr_surface surface = installationOverlay[frame]; - int iconWidth = gr_get_width(surface); - int iconHeight = gr_get_height(surface); - gr_blit(surface, 0, 0, iconWidth, iconHeight, - overlay_offset_x, overlay_offset_y); -} - // Clear the screen and draw the currently selected background icon (if any). // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_background_locked(Icon icon) @@ -114,6 +88,9 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) if (icon) { gr_surface surface = backgroundIcon[icon]; + if (icon == INSTALLING_UPDATE || icon == ERASING) { + surface = installation[installingFrame]; + } gr_surface text_surface = backgroundText[icon]; int iconWidth = gr_get_width(surface); @@ -121,16 +98,13 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) int textWidth = gr_get_width(text_surface); int textHeight = gr_get_height(text_surface); - int iconX = (gr_fb_width() - iconWidth) / 2; - int iconY = (gr_fb_height() - (iconHeight+textHeight+40)) / 2; + iconX = (gr_fb_width() - iconWidth) / 2; + iconY = (gr_fb_height() - (iconHeight+textHeight+40)) / 2; int textX = (gr_fb_width() - textWidth) / 2; int textY = ((gr_fb_height() - (iconHeight+textHeight+40)) / 2) + iconHeight + 40; gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); - if (icon == INSTALLING_UPDATE || icon == ERASING) { - draw_install_overlay_locked(installingFrame); - } gr_color(255, 255, 255, 255); gr_texticon(textX, textY, text_surface); @@ -144,7 +118,8 @@ void ScreenRecoveryUI::draw_progress_locked() if (currentIcon == ERROR) return; if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { - draw_install_overlay_locked(installingFrame); + gr_surface icon = installation[installingFrame]; + gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY); } if (progressBarType != EMPTY) { @@ -181,18 +156,6 @@ void ScreenRecoveryUI::draw_progress_locked() } } } - - if (progressBarType == INDETERMINATE) { - static int frame = 0; - gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy); - // in RTL locales, we run the animation backwards, which - // makes the spinner spin the other way. - if (rtl_locale) { - frame = (frame + indeterminate_frames - 1) % indeterminate_frames; - } else { - frame = (frame + 1) % indeterminate_frames; - } - } } } @@ -319,12 +282,6 @@ void ScreenRecoveryUI::progress_loop() { redraw = 1; } - // update the progress bar animation, if active - // skip this if we have a text overlay (too expensive to update) - if (progressBarType == INDETERMINATE && !show_text) { - redraw = 1; - } - // move the progress bar forward on timed intervals, if configured int duration = progressScopeDuration; if (progressBarType == DETERMINATE && duration > 0) { @@ -355,6 +312,13 @@ void ScreenRecoveryUI::LoadBitmap(const char* filename, gr_surface* surface) { } } +void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, gr_surface** surface) { + int result = res_create_multi_surface(filename, frames, surface); + if (result < 0) { + LOGE("missing bitmap %s\n(Code %d)\n", filename, result); + } +} + void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, gr_surface* surface) { int result = res_create_localized_surface(filename, surface); if (result < 0) { @@ -376,7 +340,9 @@ void ScreenRecoveryUI::Init() text_cols = gr_fb_width() / char_width; if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; - LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]); + backgroundIcon[NONE] = NULL; + LoadBitmapArray("icon_installing", &installing_frames, &installation); + backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : NULL; backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; LoadBitmap("icon_error", &backgroundIcon[ERROR]); backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; @@ -389,31 +355,6 @@ void ScreenRecoveryUI::Init() LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]); LoadLocalizedBitmap("error_text", &backgroundText[ERROR]); - int i; - - progressBarIndeterminate = (gr_surface*)malloc(indeterminate_frames * - sizeof(gr_surface)); - for (i = 0; i < indeterminate_frames; ++i) { - char filename[40]; - // "indeterminate01.png", "indeterminate02.png", ... - sprintf(filename, "indeterminate%02d", i+1); - LoadBitmap(filename, progressBarIndeterminate+i); - } - - if (installing_frames > 0) { - installationOverlay = (gr_surface*)malloc(installing_frames * - sizeof(gr_surface)); - for (i = 0; i < installing_frames; ++i) { - char filename[40]; - // "icon_installing_overlay01.png", - // "icon_installing_overlay02.png", ... - sprintf(filename, "icon_installing_overlay%02d", i+1); - LoadBitmap(filename, installationOverlay+i); - } - } else { - installationOverlay = NULL; - } - pthread_create(&progress_t, NULL, progress_thread, NULL); RecoveryUI::Init(); @@ -446,16 +387,6 @@ void ScreenRecoveryUI::SetBackground(Icon icon) { pthread_mutex_lock(&updateMutex); - // Adjust the offset to account for the positioning of the - // base image on the screen. - if (backgroundIcon[icon] != NULL) { - gr_surface bg = backgroundIcon[icon]; - gr_surface text = backgroundText[icon]; - overlay_offset_x = install_overlay_offset_x + (gr_fb_width() - gr_get_width(bg)) / 2; - overlay_offset_y = install_overlay_offset_y + - (gr_fb_height() - (gr_get_height(bg) + gr_get_height(text) + 40)) / 2; - } - currentIcon = icon; update_screen_locked(); @@ -495,7 +426,7 @@ void ScreenRecoveryUI::SetProgress(float fraction) if (fraction > 1.0) fraction = 1.0; if (progressBarType == DETERMINATE && fraction > progress) { // Skip updates that aren't visibly different. - int width = gr_get_width(progressBarIndeterminate[0]); + int width = gr_get_width(progressBarEmpty); float scale = width * progressScopeSize; if ((int) (progress * scale) != (int) (fraction * scale)) { progress = fraction; -- cgit v1.2.3 From 16f97c3961f08e5db7930d99e592f0a9f752df46 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 6 Mar 2014 16:16:05 -0800 Subject: remove pixelflinger from recovery Recovery now draws directly to the framebuffer by rolling its own graphics code, rather than depending on libpixelflinger. The recovery UI is modified slightly to eliminate operations that are slow with the software implementation: when the text display / menu is turned on, it now appears on a black background instead of a dimmed version of the recovery icon. There's probably substantial room for optimization of the graphics operations. Bug: 12131110 Change-Id: Iab6520e0a7aaec39e2ce39377c10aef82ae0c595 Conflicts: minui/resources.c --- screen_ui.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 38b21f84c..589c935dc 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -84,7 +84,7 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) { pagesIdentical = false; gr_color(0, 0, 0, 255); - gr_fill(0, 0, gr_fb_width(), gr_fb_height()); + gr_clear(); if (icon) { gr_surface surface = backgroundIcon[icon]; @@ -187,12 +187,12 @@ void ScreenRecoveryUI::SetColor(UIElement e) { // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_screen_locked() { - draw_background_locked(currentIcon); - draw_progress_locked(); - - if (show_text) { - SetColor(TEXT_FILL); - gr_fill(0, 0, gr_fb_width(), gr_fb_height()); + if (!show_text) { + draw_background_locked(currentIcon); + draw_progress_locked(); + } else { + gr_color(0, 0, 0, 255); + gr_clear(); int y = 0; int i = 0; -- cgit v1.2.3 From a418aa7dd5e94cbf1ab2a6fa1c63f60e5e087d42 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 17 Mar 2014 12:10:02 -0700 Subject: refactor image resource loading code in minui Reduce the number of copies of libpng boilerplate. Rename res_create_* functions to be more clear. Make explicit the use of the framebuffer pixel format for images, and handle more combinations of input and output (eg, loading a grayscale image for display rather than use as a text alpha channel). Change-Id: I3d41c800a8f4c22b2f0167967ce6ee4d6b2b8846 --- screen_ui.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 589c935dc..656f72445 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -52,6 +52,7 @@ static double now() { ScreenRecoveryUI::ScreenRecoveryUI() : currentIcon(NONE), installingFrame(0), + locale(NULL), rtl_locale(false), progressBarType(EMPTY), progressScopeStart(0), @@ -306,21 +307,21 @@ void ScreenRecoveryUI::progress_loop() { } void ScreenRecoveryUI::LoadBitmap(const char* filename, gr_surface* surface) { - int result = res_create_surface(filename, surface); + int result = res_create_display_surface(filename, surface); if (result < 0) { LOGE("missing bitmap %s\n(Code %d)\n", filename, result); } } void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, gr_surface** surface) { - int result = res_create_multi_surface(filename, frames, surface); + int result = res_create_multi_display_surface(filename, frames, surface); if (result < 0) { LOGE("missing bitmap %s\n(Code %d)\n", filename, result); } } void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, gr_surface* surface) { - int result = res_create_localized_surface(filename, surface); + int result = res_create_localized_alpha_surface(filename, locale, surface); if (result < 0) { LOGE("missing bitmap %s\n(Code %d)\n", filename, result); } @@ -360,8 +361,9 @@ void ScreenRecoveryUI::Init() RecoveryUI::Init(); } -void ScreenRecoveryUI::SetLocale(const char* locale) { - if (locale) { +void ScreenRecoveryUI::SetLocale(const char* new_locale) { + if (new_locale) { + this->locale = new_locale; char* lang = strdup(locale); for (char* p = lang; *p; ++p) { if (*p == '_') { @@ -380,6 +382,8 @@ void ScreenRecoveryUI::SetLocale(const char* locale) { rtl_locale = true; } free(lang); + } else { + new_locale = NULL; } } -- cgit v1.2.3 From 9551cf912180665a85f515c16d6412bb8ea2bf98 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 4 Apr 2014 13:48:33 -0700 Subject: make density-specific recovery assets Provide different recovery UI resources for different display densities. Right now only the text images and the progress bars are rescaled; the main icon will get scaled when it's updated for QP. Lightly quantum-ify the rest of the recovery interface. (Light background, progress bars, etc.) Change-Id: Ia639c4ce8534b01bc843524efbc4b040c1cf38b3 --- screen_ui.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index af58643dc..afe856c37 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -87,7 +87,7 @@ ScreenRecoveryUI::ScreenRecoveryUI() : void ScreenRecoveryUI::draw_background_locked(Icon icon) { pagesIdentical = false; - gr_color(0, 0, 0, 255); + gr_color(250, 250, 250, 255); gr_clear(); if (icon) { @@ -123,7 +123,7 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) } } - gr_color(255, 255, 255, 255); + gr_color(115, 115, 115, 255); gr_texticon(textX, textY, text_surface); } } @@ -148,7 +148,7 @@ void ScreenRecoveryUI::draw_progress_locked() int dy = (3*gr_fb_height() + iconHeight - 2*height)/4; // Erase behind the progress bar (in case this was a progress-only update) - gr_color(0, 0, 0, 255); + gr_color(250, 250, 250, 255); gr_fill(dx, dy, width, height); if (progressBarType == DETERMINATE) { @@ -179,20 +179,17 @@ void ScreenRecoveryUI::draw_progress_locked() void ScreenRecoveryUI::SetColor(UIElement e) { switch (e) { case HEADER: - gr_color(247, 0, 6, 255); + gr_color(0xff, 0x57, 0x22, 255); // Quantum "Deep Orange" 500 break; case MENU: case MENU_SEL_BG: - gr_color(0, 106, 157, 255); + gr_color(0x67, 0x3a, 0xb7, 255); // Quantum "Deep Purple" 500 break; case MENU_SEL_FG: gr_color(255, 255, 255, 255); break; case LOG: - gr_color(249, 194, 0, 255); - break; - case TEXT_FILL: - gr_color(0, 0, 0, 160); + gr_color(0x3f, 0x51, 0xb5, 255); // Quantum "Indigo" 500 break; default: gr_color(255, 255, 255, 255); @@ -208,7 +205,7 @@ void ScreenRecoveryUI::draw_screen_locked() draw_background_locked(currentIcon); draw_progress_locked(); } else { - gr_color(0, 0, 0, 255); + gr_color(250, 250, 250, 255); gr_clear(); int y = 0; @@ -222,13 +219,13 @@ void ScreenRecoveryUI::draw_screen_locked() if (i == menu_top + menu_sel) { // draw the highlight bar SetColor(MENU_SEL_BG); - gr_fill(0, y-2, gr_fb_width(), y+char_height+2); + gr_fill(0, y-2+kTextYOffset, gr_fb_width(), y+char_height+2+kTextYOffset); // white text of selected item SetColor(MENU_SEL_FG); - if (menu[i][0]) gr_text(4, y, menu[i], 1); + if (menu[i][0]) gr_text(kTextXOffset, y+kTextYOffset, menu[i], 1); SetColor(MENU); } else { - if (menu[i][0]) gr_text(4, y, menu[i], i < menu_top); + if (menu[i][0]) gr_text(kTextXOffset, y+kTextYOffset, menu[i], i < menu_top); } y += char_height+4; } @@ -249,7 +246,7 @@ void ScreenRecoveryUI::draw_screen_locked() for (int ty = gr_fb_height() - char_height, count = 0; ty > y+2 && count < text_rows; ty -= char_height, ++count) { - gr_text(4, ty, text[row], 0); + gr_text(kTextXOffset, ty+kTextYOffset, text[row], 0); --row; if (row < 0) row = text_rows-1; } @@ -350,11 +347,11 @@ void ScreenRecoveryUI::Init() gr_font_size(&char_width, &char_height); text_col = text_row = 0; - text_rows = gr_fb_height() / char_height; + text_rows = (gr_fb_height() - 2 * kTextYOffset) / char_height; if (text_rows > kMaxRows) text_rows = kMaxRows; text_top = 1; - text_cols = gr_fb_width() / char_width; + text_cols = (gr_fb_width() - 2 * kTextXOffset) / char_width; if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; backgroundIcon[NONE] = NULL; -- cgit v1.2.3 From 5b5f6c2fd32839227d10ee3c97e662a415b80e2b Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 3 Jun 2014 10:50:13 -0700 Subject: restore holo UI in recovery Return to the recovery to the holo appearance. Bug: 15424396 Change-Id: Id4d3f23e0a6251a12aa42f3793cff347f38b4243 --- screen_ui.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index d087af329..03ef049ae 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -89,7 +89,7 @@ ScreenRecoveryUI::ScreenRecoveryUI() : void ScreenRecoveryUI::draw_background_locked(Icon icon) { pagesIdentical = false; - gr_color(250, 250, 250, 255); + gr_color(0, 0, 0, 255); gr_clear(); if (icon) { @@ -125,7 +125,7 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) } } - gr_color(115, 115, 115, 255); + gr_color(255, 255, 255, 255); gr_texticon(textX, textY, text_surface); } } @@ -150,7 +150,7 @@ void ScreenRecoveryUI::draw_progress_locked() int dy = (3*gr_fb_height() + iconHeight - 2*height)/4; // Erase behind the progress bar (in case this was a progress-only update) - gr_color(250, 250, 250, 255); + gr_color(0, 0, 0, 255); gr_fill(dx, dy, width, height); if (progressBarType == DETERMINATE) { @@ -181,17 +181,20 @@ void ScreenRecoveryUI::draw_progress_locked() void ScreenRecoveryUI::SetColor(UIElement e) { switch (e) { case HEADER: - gr_color(0xff, 0x57, 0x22, 255); // Quantum "Deep Orange" 500 + gr_color(247, 0, 6, 255); break; case MENU: case MENU_SEL_BG: - gr_color(0x67, 0x3a, 0xb7, 255); // Quantum "Deep Purple" 500 + gr_color(0, 106, 157, 255); break; case MENU_SEL_FG: gr_color(255, 255, 255, 255); break; case LOG: - gr_color(0x3f, 0x51, 0xb5, 255); // Quantum "Indigo" 500 + gr_color(249, 194, 0, 255); + break; + case TEXT_FILL: + gr_color(0, 0, 0, 160); break; default: gr_color(255, 255, 255, 255); @@ -207,7 +210,7 @@ void ScreenRecoveryUI::draw_screen_locked() draw_background_locked(currentIcon); draw_progress_locked(); } else { - gr_color(250, 250, 250, 255); + gr_color(0, 0, 0, 255); gr_clear(); int y = 0; @@ -221,13 +224,13 @@ void ScreenRecoveryUI::draw_screen_locked() if (i == menu_top + menu_sel) { // draw the highlight bar SetColor(MENU_SEL_BG); - gr_fill(0, y-2+kTextYOffset, gr_fb_width(), y+char_height+2+kTextYOffset); + gr_fill(0, y-2, gr_fb_width(), y+char_height+2); // white text of selected item SetColor(MENU_SEL_FG); - if (menu[i][0]) gr_text(kTextXOffset, y+kTextYOffset, menu[i], 1); + if (menu[i][0]) gr_text(4, y, menu[i], 1); SetColor(MENU); } else { - if (menu[i][0]) gr_text(kTextXOffset, y+kTextYOffset, menu[i], i < menu_top); + if (menu[i][0]) gr_text(4, y, menu[i], i < menu_top); } y += char_height+4; } @@ -248,7 +251,7 @@ void ScreenRecoveryUI::draw_screen_locked() for (int ty = gr_fb_height() - char_height, count = 0; ty > y+2 && count < text_rows; ty -= char_height, ++count) { - gr_text(kTextXOffset, ty+kTextYOffset, text[row], 0); + gr_text(4, ty, text[row], 0); --row; if (row < 0) row = text_rows-1; } @@ -349,11 +352,11 @@ void ScreenRecoveryUI::Init() gr_font_size(&char_width, &char_height); text_col = text_row = 0; - text_rows = (gr_fb_height() - 2 * kTextYOffset) / char_height; + text_rows = gr_fb_height() / char_height; if (text_rows > kMaxRows) text_rows = kMaxRows; text_top = 1; - text_cols = (gr_fb_width() - 2 * kTextXOffset) / char_width; + text_cols = gr_fb_width() / char_width; if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; backgroundIcon[NONE] = NULL; -- cgit v1.2.3