From 01a4d08010d1c26cc2cb37ca62b624829a7e1506 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 24 Mar 2015 15:21:48 -0700 Subject: Fix recovery image text rendering. Previously most devices would lose the character before a line wrap. The log's text rendering was starting at offset 4 but none of the arithmetic was taking this into account. It just happened to work on the Nexus 9's 1536-pixel wide display (1536/18=85.3) but not on a device such as the Nexus 5 (1080/18=60). The only active part of this change is the change from 4 to 0 in the gr_text call. The rest is just a few bits of trivial cleanup while I was working out what was going on. Change-Id: I9279ae323c77bc8b6ea87dc0fe009aaaec6bfa0e --- screen_ui.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'screen_ui.cpp') diff --git a/screen_ui.cpp b/screen_ui.cpp index 5e3a24f..edc41ab 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -246,12 +246,11 @@ void ScreenRecoveryUI::draw_screen_locked() // display from the bottom up, until we hit the top of the // screen, the bottom of the menu, or we've displayed the // entire text buffer. - int ty; int row = (text_top+text_rows-1) % text_rows; 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(0, ty, text[row], 0); --row; if (row < 0) row = text_rows-1; } @@ -480,8 +479,7 @@ void ScreenRecoveryUI::Print(const char *fmt, ...) // This can get called before ui_init(), so be careful. pthread_mutex_lock(&updateMutex); if (text_rows > 0 && text_cols > 0) { - char *ptr; - for (ptr = buf; *ptr != '\0'; ++ptr) { + for (char* ptr = buf; *ptr != '\0'; ++ptr) { if (*ptr == '\n' || text_col >= text_cols) { text[text_row][text_col] = '\0'; text_col = 0; @@ -521,10 +519,9 @@ void ScreenRecoveryUI::StartMenu(const char* const * headers, const char* const } int ScreenRecoveryUI::SelectMenu(int sel) { - int old_sel; pthread_mutex_lock(&updateMutex); if (show_menu > 0) { - old_sel = menu_sel; + int old_sel = menu_sel; menu_sel = sel; // Wrap at top and bottom. @@ -539,7 +536,6 @@ int ScreenRecoveryUI::SelectMenu(int sel) { } void ScreenRecoveryUI::EndMenu() { - int i; pthread_mutex_lock(&updateMutex); if (show_menu > 0 && text_rows > 0 && text_cols > 0) { show_menu = 0; -- cgit v1.1