diff options
author | Doug Zongker <dougz@android.com> | 2012-12-18 16:31:27 -0800 |
---|---|---|
committer | Chirayu Desai <cdesai@cyanogenmod.org> | 2013-02-27 19:51:36 +0530 |
commit | 7bbf5cba952b881474bc07a428ca7db7a23f7ea6 (patch) | |
tree | 4fc36b718db6d52b674bda71aa9e81b78718392b | |
parent | 74341a38a3c39d330e091cd1af0f48e892acfcd0 (diff) | |
download | bootable_recovery-7bbf5cba952b881474bc07a428ca7db7a23f7ea6.zip bootable_recovery-7bbf5cba952b881474bc07a428ca7db7a23f7ea6.tar.gz bootable_recovery-7bbf5cba952b881474bc07a428ca7db7a23f7ea6.tar.bz2 |
add optional overscan compensation to recovery graphics
If your screen is a TV, it may not actually be displaying the edges of
the framebuffer. Allow specifying an overscan percentage, and move
each edge of the framebuffer in by that percent of the width/height.
(The gr_* layer just lies to the caller about the size of the
framebuffer, telling the caller it's smaller than it really is, and
offsets all drawing commands to match.)
Change-Id: I11bb2feb39ae522bd3e957a14ebdecf3609e0fdc
Conflicts:
minui/Android.mk
-rw-r--r-- | minui/Android.mk | 6 | ||||
-rw-r--r-- | minui/graphics.c | 29 | ||||
-rw-r--r-- | minui/minui.h | 2 |
3 files changed, 32 insertions, 5 deletions
diff --git a/minui/Android.mk b/minui/Android.mk index 2314b78..7a327f5 100644 --- a/minui/Android.mk +++ b/minui/Android.mk @@ -25,6 +25,12 @@ ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888) LOCAL_CFLAGS += -DRECOVERY_BGRA endif +ifneq ($(TARGET_RECOVERY_OVERSCAN_PERCENT),) + LOCAL_CFLAGS += -DOVERSCAN_PERCENT=$(TARGET_RECOVERY_OVERSCAN_PERCENT) +else + LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0 +endif + ifneq ($(BOARD_USE_CUSTOM_RECOVERY_FONT),) LOCAL_CFLAGS += -DBOARD_USE_CUSTOM_RECOVERY_FONT=$(BOARD_USE_CUSTOM_RECOVERY_FONT) endif diff --git a/minui/graphics.c b/minui/graphics.c index 358b6d9..d419598 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -65,6 +65,9 @@ static GGLSurface gr_framebuffer[NUM_BUFFERS]; static GGLSurface gr_mem_surface; static unsigned gr_active_fb = 0; static unsigned double_buffering = 0; +static int overscan_percent = OVERSCAN_PERCENT; +static int overscan_offset_x = 0; +static int overscan_offset_y = 0; static int gr_fb_fd = -1; static int gr_vt_fd = -1; @@ -137,6 +140,9 @@ static int get_framebuffer(GGLSurface *fb) return -1; } + overscan_offset_x = vi.xres * overscan_percent / 100; + overscan_offset_y = vi.yres * overscan_percent / 100; + fb->version = sizeof(*fb); fb->width = vi.xres; fb->height = vi.yres; @@ -229,6 +235,9 @@ int gr_text(int x, int y, const char *s) GRFont *font = gr_font; unsigned off; + x += overscan_offset_x; + y += overscan_offset_y; + y -= font->ascent; gl->bindTexture(gl, &font->texture); @@ -255,6 +264,9 @@ void gr_texticon(int x, int y, gr_surface icon) { } GGLContext* gl = gr_context; + x += overscan_offset_x; + y += overscan_offset_y; + gl->bindTexture(gl, (GGLSurface*) icon); 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); @@ -268,11 +280,17 @@ void gr_texticon(int x, int y, gr_surface icon) { gl->recti(gl, x, y, x+gr_get_width(icon), y+gr_get_height(icon)); } -void gr_fill(int x, int y, int w, int h) +void gr_fill(int x1, int y1, int x2, int y2) { + x1 += overscan_offset_x; + y1 += overscan_offset_y; + + x2 += overscan_offset_x; + y2 += overscan_offset_y; + GGLContext *gl = gr_context; gl->disable(gl, GGL_TEXTURE_2D); - gl->recti(gl, x, y, w, h); + gl->recti(gl, x1, y1, x2, y2); } void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) { @@ -281,6 +299,9 @@ void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) { } GGLContext *gl = gr_context; + dx += overscan_offset_x; + dy += overscan_offset_y; + gl->bindTexture(gl, (GGLSurface*) source); 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); @@ -390,12 +411,12 @@ void gr_exit(void) int gr_fb_width(void) { - return gr_framebuffer[0].width; + return gr_framebuffer[0].width - 2*overscan_offset_x; } int gr_fb_height(void) { - return gr_framebuffer[0].height; + return gr_framebuffer[0].height - 2*overscan_offset_y; } gr_pixel *gr_fb_data(void) diff --git a/minui/minui.h b/minui/minui.h index 2e2f1f4..b281898 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -32,7 +32,7 @@ void gr_flip(void); void gr_fb_blank(bool blank); void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void gr_fill(int x, int y, int w, int h); +void gr_fill(int x1, int y1, int x2, int y2); int gr_text(int x, int y, const char *s); int gr_measure(const char *s); void gr_font_size(int *x, int *y); |