diff options
author | Doug Zongker <dougz@android.com> | 2013-03-04 15:49:02 -0800 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2013-03-04 16:37:44 -0800 |
commit | 55a36ac1e01205f2cd461cd2f89d92e3b64cddd2 (patch) | |
tree | f51ded2ae67f844bfb39457b58ae2dff9f83805b /minui/graphics.c | |
parent | 869abf03e2b4d3d5e9b942fe165254969f0e5d9b (diff) | |
download | bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.zip bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.tar.gz bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.tar.bz2 |
recovery: change font for menus to be an image
Instead of representing the font used for menus and log messages in
the recovery binary, load it from a resource PNG image. This allows
different devices to substitute their own font images.
Change-Id: Ib36b86db3d01298aa7ae2b62a26ca29e6ef18014
Diffstat (limited to 'minui/graphics.c')
-rw-r--r-- | minui/graphics.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/minui/graphics.c b/minui/graphics.c index 747b2db..ba68a95 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -30,7 +30,6 @@ #include <pixelflinger/pixelflinger.h> -#include "font_10x18.h" #include "minui.h" #if defined(RECOVERY_BGRA) @@ -47,7 +46,7 @@ #define NUM_BUFFERS 2 typedef struct { - GGLSurface texture; + GGLSurface* texture; unsigned cwidth; unsigned cheight; unsigned ascent; @@ -230,12 +229,14 @@ int gr_text(int x, int y, const char *s) GRFont *font = gr_font; unsigned off; + if (!font->texture) return x; + x += overscan_offset_x; y += overscan_offset_y; y -= font->ascent; - gl->bindTexture(gl, &font->texture); + gl->bindTexture(gl, font->texture); gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); @@ -322,31 +323,21 @@ unsigned int gr_get_height(gr_surface surface) { static void gr_init_font(void) { - GGLSurface *ftex; - unsigned char *bits, *rle; - unsigned char *in, data; - gr_font = calloc(sizeof(*gr_font), 1); - ftex = &gr_font->texture; - - bits = malloc(font.width * font.height); - ftex->version = sizeof(*ftex); - ftex->width = font.width; - ftex->height = font.height; - ftex->stride = font.width; - ftex->data = (void*) bits; - ftex->format = GGL_PIXEL_FORMAT_A_8; - - in = font.rundata; - while((data = *in++)) { - memset(bits, (data & 0x80) ? 255 : 0, data & 0x7f); - bits += (data & 0x7f); + int res = res_create_surface("font", (void**)&(gr_font->texture)); + if (res != 0) { + printf("failed to read font: res=%d\n", res); + gr_font->texture = NULL; + return; } - gr_font->cwidth = font.cwidth; - gr_font->cheight = font.cheight; - gr_font->ascent = font.cheight - 2; + // interpret the grayscale as alpha + gr_font->texture->format = GGL_PIXEL_FORMAT_A_8; + + gr_font->cwidth = gr_font->texture->width / 96; + gr_font->cheight = gr_font->texture->height; + gr_font->ascent = gr_font->cheight - 2; } int gr_init(void) |