aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2015-03-24 17:21:48 -0500
committerElliott Hughes2015-03-24 17:21:48 -0500
commit01a4d08010d1c26cc2cb37ca62b624829a7e1506 (patch)
tree954ddbce66798d137c74bc773b56775900c43b11 /minui/graphics.c
parent47733eafdc37203d59a8a0a17ccfb936d2920e31 (diff)
downloadplatform-bootable-recovery-01a4d08010d1c26cc2cb37ca62b624829a7e1506.tar.gz
platform-bootable-recovery-01a4d08010d1c26cc2cb37ca62b624829a7e1506.tar.xz
platform-bootable-recovery-01a4d08010d1c26cc2cb37ca62b624829a7e1506.zip
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
Diffstat (limited to 'minui/graphics.c')
-rw-r--r--minui/graphics.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/minui/graphics.c b/minui/graphics.c
index 870ffa08..1a9be6cb 100644
--- a/minui/graphics.c
+++ b/minui/graphics.c
@@ -77,11 +77,10 @@ static void text_blend(unsigned char* src_p, int src_row_bytes,
77 unsigned char* dst_p, int dst_row_bytes, 77 unsigned char* dst_p, int dst_row_bytes,
78 int width, int height) 78 int width, int height)
79{ 79{
80 int i, j; 80 for (int j = 0; j < height; ++j) {
81 for (j = 0; j < height; ++j) {
82 unsigned char* sx = src_p; 81 unsigned char* sx = src_p;
83 unsigned char* px = dst_p; 82 unsigned char* px = dst_p;
84 for (i = 0; i < width; ++i) { 83 for (int i = 0; i < width; ++i) {
85 unsigned char a = *sx++; 84 unsigned char a = *sx++;
86 if (gr_current_a < 255) a = ((int)a * gr_current_a) / 255; 85 if (gr_current_a < 255) a = ((int)a * gr_current_a) / 255;
87 if (a == 255) { 86 if (a == 255) {
@@ -106,34 +105,33 @@ static void text_blend(unsigned char* src_p, int src_row_bytes,
106 } 105 }
107} 106}
108 107
109
110void gr_text(int x, int y, const char *s, int bold) 108void gr_text(int x, int y, const char *s, int bold)
111{ 109{
112 GRFont *font = gr_font; 110 GRFont* font = gr_font;
113 unsigned off;
114 111
115 if (!font->texture) return; 112 if (!font->texture || gr_current_a == 0) return;
116 if (gr_current_a == 0) return;
117 113
118 bold = bold && (font->texture->height != font->cheight); 114 bold = bold && (font->texture->height != font->cheight);
119 115
120 x += overscan_offset_x; 116 x += overscan_offset_x;
121 y += overscan_offset_y; 117 y += overscan_offset_y;
122 118
123 while((off = *s++)) { 119 unsigned char ch;
124 off -= 32; 120 while ((ch = *s++)) {
125 if (outside(x, y) || outside(x+font->cwidth-1, y+font->cheight-1)) break; 121 if (outside(x, y) || outside(x+font->cwidth-1, y+font->cheight-1)) break;
126 if (off < 96) {
127 122
128 unsigned char* src_p = font->texture->data + (off * font->cwidth) + 123 if (ch < ' ' || ch > '~') {
129 (bold ? font->cheight * font->texture->row_bytes : 0); 124 ch = '?';
130 unsigned char* dst_p = gr_draw->data + y*gr_draw->row_bytes + x*gr_draw->pixel_bytes; 125 }
131 126
132 text_blend(src_p, font->texture->row_bytes, 127 unsigned char* src_p = font->texture->data + ((ch - ' ') * font->cwidth) +
133 dst_p, gr_draw->row_bytes, 128 (bold ? font->cheight * font->texture->row_bytes : 0);
134 font->cwidth, font->cheight); 129 unsigned char* dst_p = gr_draw->data + y*gr_draw->row_bytes + x*gr_draw->pixel_bytes;
130
131 text_blend(src_p, font->texture->row_bytes,
132 dst_p, gr_draw->row_bytes,
133 font->cwidth, font->cheight);
135 134
136 }
137 x += font->cwidth; 135 x += font->cwidth;
138 } 136 }
139} 137}
@@ -176,14 +174,12 @@ void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a
176 174
177void gr_clear() 175void gr_clear()
178{ 176{
179 if (gr_current_r == gr_current_g && 177 if (gr_current_r == gr_current_g && gr_current_r == gr_current_b) {
180 gr_current_r == gr_current_b) {
181 memset(gr_draw->data, gr_current_r, gr_draw->height * gr_draw->row_bytes); 178 memset(gr_draw->data, gr_current_r, gr_draw->height * gr_draw->row_bytes);
182 } else { 179 } else {
183 int x, y;
184 unsigned char* px = gr_draw->data; 180 unsigned char* px = gr_draw->data;
185 for (y = 0; y < gr_draw->height; ++y) { 181 for (int y = 0; y < gr_draw->height; ++y) {
186 for (x = 0; x < gr_draw->width; ++x) { 182 for (int x = 0; x < gr_draw->width; ++x) {
187 *px++ = gr_current_r; 183 *px++ = gr_current_r;
188 *px++ = gr_current_g; 184 *px++ = gr_current_g;
189 *px++ = gr_current_b; 185 *px++ = gr_current_b;