From 79127102e40fde2669db7136f40f77ab6727c386 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 30 Aug 2017 15:23:34 -0700 Subject: [PATCH] wear_ui: Remove backgroundIcon. It's covered by the equivalent variable in ScreenRecoveryUI: GRSurface* error_icon; Also refactor WearRecoveryUI::draw_background_locked() to get it closer to ScreenRecoveryUI code. Test: Build a wearable target recovery; Run graphics test. Change-Id: I3a8d0e4dbf6fe170e4f3adde7eaf4a2043132a57 --- wear_ui.cpp | 40 ++++++---------------------------------- wear_ui.h | 8 ++------ 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/wear_ui.cpp b/wear_ui.cpp index 85c8f835..b9289d36 100644 --- a/wear_ui.cpp +++ b/wear_ui.cpp @@ -50,8 +50,6 @@ WearRecoveryUI::WearRecoveryUI() loop_frames = 60; touch_screen_allowed_ = true; - - for (size_t i = 0; i < 5; i++) backgroundIcon[i] = NULL; } int WearRecoveryUI::GetProgressBaseline() const { @@ -67,24 +65,12 @@ void WearRecoveryUI::draw_background_locked() { gr_fill(0, 0, gr_fb_width(), gr_fb_height()); if (currentIcon != NONE) { - GRSurface* surface; - if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { - if (!intro_done) { - surface = introFrames[current_frame]; - } else { - surface = loopFrames[current_frame]; - } - } else { - surface = backgroundIcon[currentIcon]; - } - - int width = gr_get_width(surface); - int height = gr_get_height(surface); - - int x = (gr_fb_width() - width) / 2; - int y = (gr_fb_height() - height) / 2; - - gr_blit(surface, 0, 0, width, height, x, y); + GRSurface* frame = GetCurrentFrame(); + int frame_width = gr_get_width(frame); + int frame_height = gr_get_height(frame); + int frame_x = (gr_fb_width() - frame_width) / 2; + int frame_y = (gr_fb_height() - frame_height) / 2; + gr_blit(frame, 0, 0, frame_width, frame_height, frame_x, frame_y); } } @@ -177,20 +163,6 @@ void WearRecoveryUI::update_progress_locked() { gr_flip(); } -bool WearRecoveryUI::Init(const std::string& locale) { - if (!ScreenRecoveryUI::Init(locale)) { - return false; - } - - LoadBitmap("icon_error", &backgroundIcon[ERROR]); - backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; - - // This leaves backgroundIcon[INSTALLING_UPDATE] and backgroundIcon[ERASING] - // as NULL which is fine since draw_background_locked() doesn't use them. - - return true; -} - void WearRecoveryUI::SetStage(int current, int max) { } diff --git a/wear_ui.h b/wear_ui.h index 9731f416..e97598bb 100644 --- a/wear_ui.h +++ b/wear_ui.h @@ -25,8 +25,6 @@ class WearRecoveryUI : public ScreenRecoveryUI { public: WearRecoveryUI(); - bool Init(const std::string& locale) override; - void SetStage(int current, int max) override; // printing messages @@ -55,14 +53,12 @@ class WearRecoveryUI : public ScreenRecoveryUI { void PrintV(const char*, bool, va_list) override; private: - GRSurface* backgroundIcon[5]; - - int menu_start, menu_end; - void draw_background_locked() override; void draw_screen_locked() override; void PutChar(char); + + int menu_start, menu_end; }; #endif // RECOVERY_WEAR_UI_H