Merge "Fix recovery image text rendering."

This commit is contained in:
Elliott Hughes
2015-03-24 22:54:37 +00:00
committed by Gerrit Code Review
3 changed files with 26 additions and 33 deletions
+3 -2
View File
@@ -1,14 +1,15 @@
LOCAL_PATH := $(call my-dir) LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_SRC_FILES := graphics.c graphics_adf.c graphics_fbdev.c events.c \ LOCAL_SRC_FILES := graphics.c graphics_adf.c graphics_fbdev.c events.c resources.c
resources.c
LOCAL_WHOLE_STATIC_LIBRARIES += libadf LOCAL_WHOLE_STATIC_LIBRARIES += libadf
LOCAL_STATIC_LIBRARIES += libpng LOCAL_STATIC_LIBRARIES += libpng
LOCAL_MODULE := libminui LOCAL_MODULE := libminui
LOCAL_CFLAGS := -std=gnu11
# This used to compare against values in double-quotes (which are just # This used to compare against values in double-quotes (which are just
# ordinary characters in this context). Strip double-quotes from the # ordinary characters in this context). Strip double-quotes from the
# value so that either will work. # value so that either will work.
+20 -24
View File
@@ -77,11 +77,10 @@ static void text_blend(unsigned char* src_p, int src_row_bytes,
unsigned char* dst_p, int dst_row_bytes, unsigned char* dst_p, int dst_row_bytes,
int width, int height) int width, int height)
{ {
int i, j; for (int j = 0; j < height; ++j) {
for (j = 0; j < height; ++j) {
unsigned char* sx = src_p; unsigned char* sx = src_p;
unsigned char* px = dst_p; unsigned char* px = dst_p;
for (i = 0; i < width; ++i) { for (int i = 0; i < width; ++i) {
unsigned char a = *sx++; unsigned char a = *sx++;
if (gr_current_a < 255) a = ((int)a * gr_current_a) / 255; if (gr_current_a < 255) a = ((int)a * gr_current_a) / 255;
if (a == 255) { if (a == 255) {
@@ -106,34 +105,33 @@ static void text_blend(unsigned char* src_p, int src_row_bytes,
} }
} }
void gr_text(int x, int y, const char *s, int bold) void gr_text(int x, int y, const char *s, int bold)
{ {
GRFont *font = gr_font; GRFont* font = gr_font;
unsigned off;
if (!font->texture) return; if (!font->texture || gr_current_a == 0) return;
if (gr_current_a == 0) return;
bold = bold && (font->texture->height != font->cheight); bold = bold && (font->texture->height != font->cheight);
x += overscan_offset_x; x += overscan_offset_x;
y += overscan_offset_y; y += overscan_offset_y;
while((off = *s++)) { unsigned char ch;
off -= 32; while ((ch = *s++)) {
if (outside(x, y) || outside(x+font->cwidth-1, y+font->cheight-1)) break; if (outside(x, y) || outside(x+font->cwidth-1, y+font->cheight-1)) break;
if (off < 96) {
unsigned char* src_p = font->texture->data + (off * font->cwidth) +
(bold ? font->cheight * font->texture->row_bytes : 0);
unsigned char* dst_p = gr_draw->data + y*gr_draw->row_bytes + x*gr_draw->pixel_bytes;
text_blend(src_p, font->texture->row_bytes,
dst_p, gr_draw->row_bytes,
font->cwidth, font->cheight);
if (ch < ' ' || ch > '~') {
ch = '?';
} }
unsigned char* src_p = font->texture->data + ((ch - ' ') * font->cwidth) +
(bold ? font->cheight * font->texture->row_bytes : 0);
unsigned char* dst_p = gr_draw->data + y*gr_draw->row_bytes + x*gr_draw->pixel_bytes;
text_blend(src_p, font->texture->row_bytes,
dst_p, gr_draw->row_bytes,
font->cwidth, font->cheight);
x += font->cwidth; x += font->cwidth;
} }
} }
@@ -176,14 +174,12 @@ void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a
void gr_clear() void gr_clear()
{ {
if (gr_current_r == gr_current_g && if (gr_current_r == gr_current_g && gr_current_r == gr_current_b) {
gr_current_r == gr_current_b) {
memset(gr_draw->data, gr_current_r, gr_draw->height * gr_draw->row_bytes); memset(gr_draw->data, gr_current_r, gr_draw->height * gr_draw->row_bytes);
} else { } else {
int x, y;
unsigned char* px = gr_draw->data; unsigned char* px = gr_draw->data;
for (y = 0; y < gr_draw->height; ++y) { for (int y = 0; y < gr_draw->height; ++y) {
for (x = 0; x < gr_draw->width; ++x) { for (int x = 0; x < gr_draw->width; ++x) {
*px++ = gr_current_r; *px++ = gr_current_r;
*px++ = gr_current_g; *px++ = gr_current_g;
*px++ = gr_current_b; *px++ = gr_current_b;
+3 -7
View File
@@ -246,12 +246,11 @@ void ScreenRecoveryUI::draw_screen_locked()
// display from the bottom up, until we hit the top of the // display from the bottom up, until we hit the top of the
// screen, the bottom of the menu, or we've displayed the // screen, the bottom of the menu, or we've displayed the
// entire text buffer. // entire text buffer.
int ty;
int row = (text_top+text_rows-1) % text_rows; int row = (text_top+text_rows-1) % text_rows;
for (int ty = gr_fb_height() - char_height, count = 0; for (int ty = gr_fb_height() - char_height, count = 0;
ty > y+2 && count < text_rows; ty > y+2 && count < text_rows;
ty -= char_height, ++count) { ty -= char_height, ++count) {
gr_text(4, ty, text[row], 0); gr_text(0, ty, text[row], 0);
--row; --row;
if (row < 0) row = text_rows-1; 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. // This can get called before ui_init(), so be careful.
pthread_mutex_lock(&updateMutex); pthread_mutex_lock(&updateMutex);
if (text_rows > 0 && text_cols > 0) { if (text_rows > 0 && text_cols > 0) {
char *ptr; for (char* ptr = buf; *ptr != '\0'; ++ptr) {
for (ptr = buf; *ptr != '\0'; ++ptr) {
if (*ptr == '\n' || text_col >= text_cols) { if (*ptr == '\n' || text_col >= text_cols) {
text[text_row][text_col] = '\0'; text[text_row][text_col] = '\0';
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 ScreenRecoveryUI::SelectMenu(int sel) {
int old_sel;
pthread_mutex_lock(&updateMutex); pthread_mutex_lock(&updateMutex);
if (show_menu > 0) { if (show_menu > 0) {
old_sel = menu_sel; int old_sel = menu_sel;
menu_sel = sel; menu_sel = sel;
// Wrap at top and bottom. // Wrap at top and bottom.
@@ -539,7 +536,6 @@ int ScreenRecoveryUI::SelectMenu(int sel) {
} }
void ScreenRecoveryUI::EndMenu() { void ScreenRecoveryUI::EndMenu() {
int i;
pthread_mutex_lock(&updateMutex); pthread_mutex_lock(&updateMutex);
if (show_menu > 0 && text_rows > 0 && text_cols > 0) { if (show_menu > 0 && text_rows > 0 && text_cols > 0) {
show_menu = 0; show_menu = 0;