Skip to content

Commit

Permalink
recovery: sync with current graphics
Browse files Browse the repository at this point in the history
  • Loading branch information
pershoot committed Mar 2, 2013
1 parent cb8ffe0 commit 09c9e4a
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions recovery/graphics.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -387,12 +408,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)
Expand Down

0 comments on commit 09c9e4a

Please sign in to comment.