simplify construction of the recovery progress bar
Instead of six separate images for the left end, right end, and tiled center portion of the full and empty progress bars, just use two images: a full bar and an empty bar. Draw the left side of the full bar and the right side of the empty one, moving the boundary rightward to "fill" the bar. This makes recovery trivially smaller, and allows fancier images to be used as progress bars. Support paletted PNG images as resources.
@@ -97,9 +97,10 @@ int res_create_surface(const char* name, gr_surface* pSurface) {
|
|||||||
int color_type = info_ptr->color_type;
|
int color_type = info_ptr->color_type;
|
||||||
int bit_depth = info_ptr->bit_depth;
|
int bit_depth = info_ptr->bit_depth;
|
||||||
int channels = info_ptr->channels;
|
int channels = info_ptr->channels;
|
||||||
if (bit_depth != 8 || (channels != 3 && channels != 4) ||
|
if (!(bit_depth == 8 &&
|
||||||
(color_type != PNG_COLOR_TYPE_RGB &&
|
((channels == 3 && color_type == PNG_COLOR_TYPE_RGB) ||
|
||||||
color_type != PNG_COLOR_TYPE_RGBA)) {
|
(channels == 4 && color_type == PNG_COLOR_TYPE_RGBA) ||
|
||||||
|
(channels == 1 && color_type == PNG_COLOR_TYPE_PALETTE)))) {
|
||||||
return -7;
|
return -7;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@@ -118,6 +119,10 @@ int res_create_surface(const char* name, gr_surface* pSurface) {
|
|||||||
surface->format = (channels == 3) ?
|
surface->format = (channels == 3) ?
|
||||||
GGL_PIXEL_FORMAT_RGBX_8888 : GGL_PIXEL_FORMAT_RGBA_8888;
|
GGL_PIXEL_FORMAT_RGBX_8888 : GGL_PIXEL_FORMAT_RGBA_8888;
|
||||||
|
|
||||||
|
if (color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||||
|
png_set_palette_to_rgb(png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
int y;
|
int y;
|
||||||
if (channels == 3) {
|
if (channels == 3) {
|
||||||
for (y = 0; y < height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 148 B |
|
Before Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 211 B |
|
Before Width: | Height: | Size: 117 B |
|
Before Width: | Height: | Size: 195 B |
|
Before Width: | Height: | Size: 192 B |
|
After Width: | Height: | Size: 361 B |
|
After Width: | Height: | Size: 286 B |
@@ -38,13 +38,11 @@
|
|||||||
#define PROGRESSBAR_INDETERMINATE_STATES 6
|
#define PROGRESSBAR_INDETERMINATE_STATES 6
|
||||||
#define PROGRESSBAR_INDETERMINATE_FPS 15
|
#define PROGRESSBAR_INDETERMINATE_FPS 15
|
||||||
|
|
||||||
enum { LEFT_SIDE, CENTER_TILE, RIGHT_SIDE, NUM_SIDES };
|
|
||||||
|
|
||||||
static pthread_mutex_t gUpdateMutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t gUpdateMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static gr_surface gBackgroundIcon[NUM_BACKGROUND_ICONS];
|
static gr_surface gBackgroundIcon[NUM_BACKGROUND_ICONS];
|
||||||
static gr_surface gProgressBarIndeterminate[PROGRESSBAR_INDETERMINATE_STATES];
|
static gr_surface gProgressBarIndeterminate[PROGRESSBAR_INDETERMINATE_STATES];
|
||||||
static gr_surface gProgressBarEmpty[NUM_SIDES];
|
static gr_surface gProgressBarEmpty;
|
||||||
static gr_surface gProgressBarFill[NUM_SIDES];
|
static gr_surface gProgressBarFill;
|
||||||
|
|
||||||
static const struct { gr_surface* surface; const char *name; } BITMAPS[] = {
|
static const struct { gr_surface* surface; const char *name; } BITMAPS[] = {
|
||||||
{ &gBackgroundIcon[BACKGROUND_ICON_INSTALLING], "icon_installing" },
|
{ &gBackgroundIcon[BACKGROUND_ICON_INSTALLING], "icon_installing" },
|
||||||
@@ -59,12 +57,8 @@ static const struct { gr_surface* surface; const char *name; } BITMAPS[] = {
|
|||||||
{ &gProgressBarIndeterminate[3], "indeterminate4" },
|
{ &gProgressBarIndeterminate[3], "indeterminate4" },
|
||||||
{ &gProgressBarIndeterminate[4], "indeterminate5" },
|
{ &gProgressBarIndeterminate[4], "indeterminate5" },
|
||||||
{ &gProgressBarIndeterminate[5], "indeterminate6" },
|
{ &gProgressBarIndeterminate[5], "indeterminate6" },
|
||||||
{ &gProgressBarEmpty[LEFT_SIDE], "progress_bar_empty_left_round" },
|
{ &gProgressBarEmpty, "progress_empty" },
|
||||||
{ &gProgressBarEmpty[CENTER_TILE], "progress_bar_empty" },
|
{ &gProgressBarFill, "progress_fill" },
|
||||||
{ &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" },
|
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -123,8 +117,8 @@ static void draw_progress_locked()
|
|||||||
if (gProgressBarType == PROGRESSBAR_TYPE_NONE) return;
|
if (gProgressBarType == PROGRESSBAR_TYPE_NONE) return;
|
||||||
|
|
||||||
int iconHeight = gr_get_height(gBackgroundIcon[BACKGROUND_ICON_INSTALLING]);
|
int iconHeight = gr_get_height(gBackgroundIcon[BACKGROUND_ICON_INSTALLING]);
|
||||||
int width = gr_get_width(gProgressBarIndeterminate[0]);
|
int width = gr_get_width(gProgressBarEmpty);
|
||||||
int height = gr_get_height(gProgressBarIndeterminate[0]);
|
int height = gr_get_height(gProgressBarEmpty);
|
||||||
|
|
||||||
int dx = (gr_fb_width() - width)/2;
|
int dx = (gr_fb_width() - width)/2;
|
||||||
int dy = (3*gr_fb_height() + iconHeight - 2*height)/4;
|
int dy = (3*gr_fb_height() + iconHeight - 2*height)/4;
|
||||||
@@ -137,18 +131,12 @@ static void draw_progress_locked()
|
|||||||
float progress = gProgressScopeStart + gProgress * gProgressScopeSize;
|
float progress = gProgressScopeStart + gProgress * gProgressScopeSize;
|
||||||
int pos = (int) (progress * width);
|
int pos = (int) (progress * width);
|
||||||
|
|
||||||
gr_surface s = (pos ? gProgressBarFill : gProgressBarEmpty)[LEFT_SIDE];
|
if (pos > 0) {
|
||||||
gr_blit(s, 0, 0, gr_get_width(s), gr_get_height(s), dx, dy);
|
gr_blit(gProgressBarFill, 0, 0, pos, height, dx, dy);
|
||||||
|
}
|
||||||
int x = gr_get_width(s);
|
if (pos < width-1) {
|
||||||
while (x + (int) gr_get_width(gProgressBarEmpty[RIGHT_SIDE]) < width) {
|
gr_blit(gProgressBarEmpty, pos, 0, width-pos, height, dx+pos, dy);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (gProgressBarType == PROGRESSBAR_TYPE_INDETERMINATE) {
|
||||||
|
|||||||