summaryrefslogtreecommitdiffstats
path: root/ui.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ui.c55
1 files changed, 11 insertions, 44 deletions
diff --git a/ui.c b/ui.c
index 51df1fa9f..01a005f80 100644
--- a/ui.c
+++ b/ui.c
@@ -38,33 +38,23 @@
#define PROGRESSBAR_INDETERMINATE_STATES 6
#define PROGRESSBAR_INDETERMINATE_FPS 15
-enum { LEFT_SIDE, CENTER_TILE, RIGHT_SIDE, NUM_SIDES };
-
static pthread_mutex_t gUpdateMutex = PTHREAD_MUTEX_INITIALIZER;
static gr_surface gBackgroundIcon[NUM_BACKGROUND_ICONS];
static gr_surface gProgressBarIndeterminate[PROGRESSBAR_INDETERMINATE_STATES];
-static gr_surface gProgressBarEmpty[NUM_SIDES];
-static gr_surface gProgressBarFill[NUM_SIDES];
+static gr_surface gProgressBarEmpty;
+static gr_surface gProgressBarFill;
static const struct { gr_surface* surface; const char *name; } BITMAPS[] = {
{ &gBackgroundIcon[BACKGROUND_ICON_INSTALLING], "icon_installing" },
{ &gBackgroundIcon[BACKGROUND_ICON_ERROR], "icon_error" },
- { &gBackgroundIcon[BACKGROUND_ICON_FIRMWARE_INSTALLING],
- "icon_firmware_install" },
- { &gBackgroundIcon[BACKGROUND_ICON_FIRMWARE_ERROR],
- "icon_firmware_error" },
{ &gProgressBarIndeterminate[0], "indeterminate1" },
{ &gProgressBarIndeterminate[1], "indeterminate2" },
{ &gProgressBarIndeterminate[2], "indeterminate3" },
{ &gProgressBarIndeterminate[3], "indeterminate4" },
{ &gProgressBarIndeterminate[4], "indeterminate5" },
{ &gProgressBarIndeterminate[5], "indeterminate6" },
- { &gProgressBarEmpty[LEFT_SIDE], "progress_bar_empty_left_round" },
- { &gProgressBarEmpty[CENTER_TILE], "progress_bar_empty" },
- { &gProgressBarEmpty[RIGHT_SIDE], "progress_bar_empty_right_round" },
- { &gProgressBarFill[LEFT_SIDE], "progress_bar_left_round" },
- { &gProgressBarFill[CENTER_TILE], "progress_bar_fill" },
- { &gProgressBarFill[RIGHT_SIDE], "progress_bar_right_round" },
+ { &gProgressBarEmpty, "progress_empty" },
+ { &gProgressBarFill, "progress_fill" },
{ NULL, NULL },
};
@@ -123,8 +113,8 @@ static void draw_progress_locked()
if (gProgressBarType == PROGRESSBAR_TYPE_NONE) return;
int iconHeight = gr_get_height(gBackgroundIcon[BACKGROUND_ICON_INSTALLING]);
- int width = gr_get_width(gProgressBarIndeterminate[0]);
- int height = gr_get_height(gProgressBarIndeterminate[0]);
+ int width = gr_get_width(gProgressBarEmpty);
+ int height = gr_get_height(gProgressBarEmpty);
int dx = (gr_fb_width() - width)/2;
int dy = (3*gr_fb_height() + iconHeight - 2*height)/4;
@@ -137,18 +127,12 @@ static void draw_progress_locked()
float progress = gProgressScopeStart + gProgress * gProgressScopeSize;
int pos = (int) (progress * width);
- gr_surface s = (pos ? gProgressBarFill : gProgressBarEmpty)[LEFT_SIDE];
- gr_blit(s, 0, 0, gr_get_width(s), gr_get_height(s), dx, dy);
-
- int x = gr_get_width(s);
- while (x + (int) gr_get_width(gProgressBarEmpty[RIGHT_SIDE]) < width) {
- s = (pos > x ? gProgressBarFill : gProgressBarEmpty)[CENTER_TILE];
- gr_blit(s, 0, 0, gr_get_width(s), gr_get_height(s), dx + x, dy);
- x += gr_get_width(s);
+ if (pos > 0) {
+ gr_blit(gProgressBarFill, 0, 0, pos, height, dx, dy);
+ }
+ if (pos < width-1) {
+ gr_blit(gProgressBarEmpty, pos, 0, width-pos, height, dx+pos, dy);
}
-
- s = (pos > x ? gProgressBarFill : gProgressBarEmpty)[RIGHT_SIDE];
- gr_blit(s, 0, 0, gr_get_width(s), gr_get_height(s), dx + x, dy);
}
if (gProgressBarType == PROGRESSBAR_TYPE_INDETERMINATE) {
@@ -353,23 +337,6 @@ void ui_init(void)
pthread_create(&t, NULL, input_thread, NULL);
}
-char *ui_copy_image(int icon, int *width, int *height, int *bpp) {
- pthread_mutex_lock(&gUpdateMutex);
- draw_background_locked(gBackgroundIcon[icon]);
- *width = gr_fb_width();
- *height = gr_fb_height();
- *bpp = sizeof(gr_pixel) * 8;
- int size = *width * *height * sizeof(gr_pixel);
- char *ret = malloc(size);
- if (ret == NULL) {
- LOGE("Can't allocate %d bytes for image\n", size);
- } else {
- memcpy(ret, gr_fb_data(), size);
- }
- pthread_mutex_unlock(&gUpdateMutex);
- return ret;
-}
-
void ui_set_background(int icon)
{
pthread_mutex_lock(&gUpdateMutex);