diff options
author | Vojtech Bocek <vbocek@gmail.com> | 2015-03-05 20:02:57 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2015-03-11 13:59:15 +0100 |
commit | db378b6cbb00296a9032aa8fc8a47961f6fced68 (patch) | |
tree | 9db94bc5cea968e22512af89838bc08c33d2e06c /minuitwrp | |
parent | gui: support string resources (diff) | |
download | android_bootable_recovery-db378b6cbb00296a9032aa8fc8a47961f6fced68.tar android_bootable_recovery-db378b6cbb00296a9032aa8fc8a47961f6fced68.tar.gz android_bootable_recovery-db378b6cbb00296a9032aa8fc8a47961f6fced68.tar.bz2 android_bootable_recovery-db378b6cbb00296a9032aa8fc8a47961f6fced68.tar.lz android_bootable_recovery-db378b6cbb00296a9032aa8fc8a47961f6fced68.tar.xz android_bootable_recovery-db378b6cbb00296a9032aa8fc8a47961f6fced68.tar.zst android_bootable_recovery-db378b6cbb00296a9032aa8fc8a47961f6fced68.zip |
Diffstat (limited to '')
-rw-r--r-- | minuitwrp/graphics.c | 45 | ||||
-rw-r--r-- | minuitwrp/minui.h | 2 |
2 files changed, 47 insertions, 0 deletions
diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c index 7160c7e2e..077211064 100644 --- a/minuitwrp/graphics.c +++ b/minuitwrp/graphics.c @@ -586,6 +586,51 @@ void gr_fill(int x, int y, int w, int h) gl->enable(gl, GGL_BLEND); } +void gr_line(int x0, int y0, int x1, int y1, int width) +{ + GGLContext *gl = gr_context; + + if(gr_is_curr_clr_opaque) + gl->disable(gl, GGL_BLEND); + + const int coords0[2] = { x0 << 4, y0 << 4 }; + const int coords1[2] = { x1 << 4, y1 << 4 }; + gl->linex(gl, coords0, coords1, width << 4); + + if(gr_is_curr_clr_opaque) + gl->enable(gl, GGL_BLEND); +} + +gr_surface gr_render_circle(int radius, unsigned char r, unsigned char g, unsigned char b, unsigned char a) +{ + int rx, ry; + GGLSurface *surface; + const int diameter = radius*2 + 1; + const int radius_check = radius*radius + radius*0.8; + const uint32_t px = (a << 24) | (b << 16) | (g << 8) | r; + uint32_t *data; + + surface = malloc(sizeof(GGLSurface)); + memset(surface, 0, sizeof(GGLSurface)); + + data = malloc(diameter * diameter * 4); + memset(data, 0, diameter * diameter * 4); + + surface->version = sizeof(surface); + surface->width = diameter; + surface->height = diameter; + surface->stride = diameter; + surface->data = (GGLubyte*)data; + surface->format = GGL_PIXEL_FORMAT_RGBA_8888; + + for(ry = -radius; ry <= radius; ++ry) + for(rx = -radius; rx <= radius; ++rx) + if(rx*rx+ry*ry <= radius_check) + *(data + diameter*(radius + ry) + (radius+rx)) = px; + + return surface; +} + void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) { if (gr_context == NULL) { return; diff --git a/minuitwrp/minui.h b/minuitwrp/minui.h index 8ef04445c..6033da728 100644 --- a/minuitwrp/minui.h +++ b/minuitwrp/minui.h @@ -39,6 +39,8 @@ void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a void gr_clip(int x, int y, int w, int h); void gr_noclip(); void gr_fill(int x, int y, int w, int h); +void gr_line(int x0, int y0, int x1, int y1, int width); +gr_surface gr_render_circle(int radius, unsigned char r, unsigned char g, unsigned char b, unsigned char a); int gr_textEx(int x, int y, const char *s, void* font); int gr_textExW(int x, int y, const char *s, void* font, int max_width); |