aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Zongker2014-03-11 21:39:26 -0500
committerDoug Zongker2014-03-11 21:39:26 -0500
commitc15b7865badc3ac406a7ce978baa65151a50bb55 (patch)
tree4298bb59e37a9f1ea05e89391564c3bb13f75732
parent49968f0903eb69b1505bc99926344aacee4e81b6 (diff)
parentea868b3846794cd36424f477503377ea9348137a (diff)
downloadplatform-bootable-recovery-c15b7865badc3ac406a7ce978baa65151a50bb55.tar.gz
platform-bootable-recovery-c15b7865badc3ac406a7ce978baa65151a50bb55.tar.xz
platform-bootable-recovery-c15b7865badc3ac406a7ce978baa65151a50bb55.zip
resolved conflicts for merge of ea868b38 to klp-modular-dev-plus-aosp
Change-Id: I8cc3b8101bccf7fd697f9a7b73732d1000dc27a1
-rw-r--r--minui/minui.h1
-rw-r--r--minui/resources.c182
-rw-r--r--res/images/icon_installing.pngbin25261 -> 118562 bytes
-rw-r--r--res/images/icon_installing_overlay01.pngbin10095 -> 0 bytes
-rw-r--r--res/images/icon_installing_overlay02.pngbin9990 -> 0 bytes
-rw-r--r--res/images/icon_installing_overlay03.pngbin9782 -> 0 bytes
-rw-r--r--res/images/icon_installing_overlay04.pngbin9817 -> 0 bytes
-rw-r--r--res/images/icon_installing_overlay05.pngbin9863 -> 0 bytes
-rw-r--r--res/images/icon_installing_overlay06.pngbin9944 -> 0 bytes
-rw-r--r--res/images/icon_installing_overlay07.pngbin10062 -> 0 bytes
-rw-r--r--res/images/indeterminate01.pngbin673 -> 0 bytes
-rw-r--r--res/images/indeterminate02.pngbin687 -> 0 bytes
-rw-r--r--res/images/indeterminate03.pngbin661 -> 0 bytes
-rw-r--r--res/images/indeterminate04.pngbin665 -> 0 bytes
-rw-r--r--res/images/indeterminate05.pngbin683 -> 0 bytes
-rw-r--r--res/images/indeterminate06.pngbin676 -> 0 bytes
-rw-r--r--screen_ui.cpp112
-rw-r--r--screen_ui.h11
18 files changed, 204 insertions, 102 deletions
diff --git a/minui/minui.h b/minui/minui.h
index 1b8dd059..5c0defc4 100644
--- a/minui/minui.h
+++ b/minui/minui.h
@@ -72,6 +72,7 @@ void ev_dispatch(void);
72 72
73// Returns 0 if no error, else negative. 73// Returns 0 if no error, else negative.
74int res_create_surface(const char* name, gr_surface* pSurface); 74int res_create_surface(const char* name, gr_surface* pSurface);
75int res_create_multi_surface(const char* name, int* frames, gr_surface** pSurface);
75int res_create_localized_surface(const char* name, gr_surface* pSurface); 76int res_create_localized_surface(const char* name, gr_surface* pSurface);
76void res_free_surface(gr_surface surface); 77void res_free_surface(gr_surface surface);
77 78
diff --git a/minui/resources.c b/minui/resources.c
index c0a9ccac..5ad9b1d0 100644
--- a/minui/resources.c
+++ b/minui/resources.c
@@ -181,6 +181,182 @@ exit:
181 return result; 181 return result;
182} 182}
183 183
184int res_create_multi_surface(const char* name, int* frames, gr_surface** pSurface) {
185 char resPath[256];
186 int result = 0;
187 unsigned char header[8];
188 png_structp png_ptr = NULL;
189 png_infop info_ptr = NULL;
190 int i;
191 GGLSurface** surface = NULL;
192
193 *pSurface = NULL;
194 *frames = -1;
195
196 snprintf(resPath, sizeof(resPath)-1, "/res/images/%s.png", name);
197 resPath[sizeof(resPath)-1] = '\0';
198 FILE* fp = fopen(resPath, "rb");
199 if (fp == NULL) {
200 result = -1;
201 goto exit;
202 }
203
204 size_t bytesRead = fread(header, 1, sizeof(header), fp);
205 if (bytesRead != sizeof(header)) {
206 result = -2;
207 goto exit;
208 }
209
210 if (png_sig_cmp(header, 0, sizeof(header))) {
211 result = -3;
212 goto exit;
213 }
214
215 png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
216 if (!png_ptr) {
217 result = -4;
218 goto exit;
219 }
220
221 info_ptr = png_create_info_struct(png_ptr);
222 if (!info_ptr) {
223 result = -5;
224 goto exit;
225 }
226
227 if (setjmp(png_jmpbuf(png_ptr))) {
228 result = -6;
229 goto exit;
230 }
231
232 png_init_io(png_ptr, fp);
233 png_set_sig_bytes(png_ptr, sizeof(header));
234 png_read_info(png_ptr, info_ptr);
235
236 int color_type, bit_depth;
237 png_uint_32 width, height;
238 png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
239 &color_type, NULL, NULL, NULL);
240
241 int channels = png_get_channels(png_ptr, info_ptr);
242
243 if (!(bit_depth == 8 &&
244 ((channels == 3 && color_type == PNG_COLOR_TYPE_RGB) ||
245 (channels == 4 && color_type == PNG_COLOR_TYPE_RGBA) ||
246 (channels == 1 && (color_type == PNG_COLOR_TYPE_PALETTE ||
247 color_type == PNG_COLOR_TYPE_GRAY))))) {
248 return -7;
249 goto exit;
250 }
251
252 *frames = 1;
253 png_textp text;
254 int num_text;
255 if (png_get_text(png_ptr, info_ptr, &text, &num_text)) {
256 for (i = 0; i < num_text; ++i) {
257 if (text[i].key && strcmp(text[i].key, "Frames") == 0 && text[i].text) {
258 *frames = atoi(text[i].text);
259 break;
260 }
261 }
262 printf(" found frames = %d\n", *frames);
263 }
264
265 if (height % *frames != 0) {
266 printf("bad height (%d) for frame count (%d)\n", height, *frames);
267 result = -9;
268 goto exit;
269 }
270
271 size_t stride = (color_type == PNG_COLOR_TYPE_GRAY ? 1 : 4) * width;
272 size_t pixelSize = stride * height / *frames;
273
274 surface = malloc(*frames * sizeof(GGLSurface*));
275 if (surface == NULL) {
276 result = -8;
277 goto exit;
278 }
279 for (i = 0; i < *frames; ++i) {
280 surface[i] = malloc(sizeof(GGLSurface) + pixelSize);
281 surface[i]->version = sizeof(GGLSurface);
282 surface[i]->width = width;
283 surface[i]->height = height / *frames;
284 surface[i]->stride = width; /* Yes, pixels, not bytes */
285 surface[i]->data = (unsigned char*) (surface[i] + 1);
286
287 if (channels == 3) {
288 surface[i]->format = GGL_PIXEL_FORMAT_RGBX_8888;
289 } else if (color_type == PNG_COLOR_TYPE_PALETTE) {
290 surface[i]->format = GGL_PIXEL_FORMAT_RGBA_8888;
291 } else if (channels == 1) {
292 surface[i]->format = GGL_PIXEL_FORMAT_L_8;
293 } else {
294 surface[i]->format = GGL_PIXEL_FORMAT_RGBA_8888;
295 }
296 }
297
298 int alpha = (channels == 4);
299 if (color_type == PNG_COLOR_TYPE_PALETTE) {
300 png_set_palette_to_rgb(png_ptr);
301 }
302 if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
303 png_set_tRNS_to_alpha(png_ptr);
304 alpha = 1;
305 }
306 if (color_type == PNG_COLOR_TYPE_GRAY) {
307 alpha = 1;
308 }
309
310 png_uint_32 y;
311 if (channels == 3 || (channels == 1 && !alpha)) {
312 for (y = 0; y < height; ++y) {
313 int fy = y / *frames;
314 int fr = y % *frames;
315 unsigned char* pRow = surface[fr]->data + fy * stride;
316 png_read_row(png_ptr, pRow, NULL);
317
318 int x;
319 for(x = width - 1; x >= 0; x--) {
320 int sx = x * 3;
321 int dx = x * 4;
322 unsigned char r = pRow[sx];
323 unsigned char g = pRow[sx + 1];
324 unsigned char b = pRow[sx + 2];
325 unsigned char a = 0xff;
326 pRow[dx ] = r; // r
327 pRow[dx + 1] = g; // g
328 pRow[dx + 2] = b; // b
329 pRow[dx + 3] = a;
330 }
331 }
332 } else {
333 for (y = 0; y < height; ++y) {
334 int fy = y / *frames;
335 int fr = y % *frames;
336 unsigned char* pRow = surface[fr]->data + fy * stride;
337 png_read_row(png_ptr, pRow, NULL);
338 }
339 }
340
341 *pSurface = (gr_surface*) surface;
342
343exit:
344 png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
345
346 if (fp != NULL) {
347 fclose(fp);
348 }
349 if (result < 0) {
350 if (surface) {
351 for (i = 0; i < *frames; ++i) {
352 if (surface[i]) free(surface[i]);
353 }
354 free(surface);
355 }
356 }
357 return result;
358}
359
184static int matches_locale(const char* loc) { 360static int matches_locale(const char* loc) {
185 if (locale == NULL) return 0; 361 if (locale == NULL) return 0;
186 362
@@ -249,7 +425,7 @@ int res_create_localized_surface(const char* name, gr_surface* pSurface) {
249 png_read_info(png_ptr, info_ptr); 425 png_read_info(png_ptr, info_ptr);
250 426
251 int color_type, bit_depth; 427 int color_type, bit_depth;
252 size_t width, height; 428 png_uint_32 width, height;
253 png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, 429 png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
254 &color_type, NULL, NULL, NULL); 430 &color_type, NULL, NULL, NULL);
255 int channels = png_get_channels(png_ptr, info_ptr); 431 int channels = png_get_channels(png_ptr, info_ptr);
@@ -261,13 +437,13 @@ int res_create_localized_surface(const char* name, gr_surface* pSurface) {
261 } 437 }
262 438
263 unsigned char* row = malloc(width); 439 unsigned char* row = malloc(width);
264 int y; 440 png_uint_32 y;
265 for (y = 0; y < height; ++y) { 441 for (y = 0; y < height; ++y) {
266 png_read_row(png_ptr, row, NULL); 442 png_read_row(png_ptr, row, NULL);
267 int w = (row[1] << 8) | row[0]; 443 int w = (row[1] << 8) | row[0];
268 int h = (row[3] << 8) | row[2]; 444 int h = (row[3] << 8) | row[2];
269 int len = row[4]; 445 int len = row[4];
270 char* loc = row+5; 446 char* loc = (char*)row+5;
271 447
272 if (y+1+h >= height || matches_locale(loc)) { 448 if (y+1+h >= height || matches_locale(loc)) {
273 printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y); 449 printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y);
diff --git a/res/images/icon_installing.png b/res/images/icon_installing.png
index 571eb8b0..c2c02016 100644
--- a/res/images/icon_installing.png
+++ b/res/images/icon_installing.png
Binary files differ
diff --git a/res/images/icon_installing_overlay01.png b/res/images/icon_installing_overlay01.png
deleted file mode 100644
index e762d6cb..00000000
--- a/res/images/icon_installing_overlay01.png
+++ /dev/null
Binary files differ
diff --git a/res/images/icon_installing_overlay02.png b/res/images/icon_installing_overlay02.png
deleted file mode 100644
index f7a85301..00000000
--- a/res/images/icon_installing_overlay02.png
+++ /dev/null
Binary files differ
diff --git a/res/images/icon_installing_overlay03.png b/res/images/icon_installing_overlay03.png
deleted file mode 100644
index 1a1d738e..00000000
--- a/res/images/icon_installing_overlay03.png
+++ /dev/null
Binary files differ
diff --git a/res/images/icon_installing_overlay04.png b/res/images/icon_installing_overlay04.png
deleted file mode 100644
index a74903d3..00000000
--- a/res/images/icon_installing_overlay04.png
+++ /dev/null
Binary files differ
diff --git a/res/images/icon_installing_overlay05.png b/res/images/icon_installing_overlay05.png
deleted file mode 100644
index d17bdc00..00000000
--- a/res/images/icon_installing_overlay05.png
+++ /dev/null
Binary files differ
diff --git a/res/images/icon_installing_overlay06.png b/res/images/icon_installing_overlay06.png
deleted file mode 100644
index 1200b75c..00000000
--- a/res/images/icon_installing_overlay06.png
+++ /dev/null
Binary files differ
diff --git a/res/images/icon_installing_overlay07.png b/res/images/icon_installing_overlay07.png
deleted file mode 100644
index 3838a85a..00000000
--- a/res/images/icon_installing_overlay07.png
+++ /dev/null
Binary files differ
diff --git a/res/images/indeterminate01.png b/res/images/indeterminate01.png
deleted file mode 100644
index 933528d6..00000000
--- a/res/images/indeterminate01.png
+++ /dev/null
Binary files differ
diff --git a/res/images/indeterminate02.png b/res/images/indeterminate02.png
deleted file mode 100644
index d760e2bd..00000000
--- a/res/images/indeterminate02.png
+++ /dev/null
Binary files differ
diff --git a/res/images/indeterminate03.png b/res/images/indeterminate03.png
deleted file mode 100644
index 0e97399d..00000000
--- a/res/images/indeterminate03.png
+++ /dev/null
Binary files differ
diff --git a/res/images/indeterminate04.png b/res/images/indeterminate04.png
deleted file mode 100644
index c7d5b4e0..00000000
--- a/res/images/indeterminate04.png
+++ /dev/null
Binary files differ
diff --git a/res/images/indeterminate05.png b/res/images/indeterminate05.png
deleted file mode 100644
index d6fb2a03..00000000
--- a/res/images/indeterminate05.png
+++ /dev/null
Binary files differ
diff --git a/res/images/indeterminate06.png b/res/images/indeterminate06.png
deleted file mode 100644
index 44867619..00000000
--- a/res/images/indeterminate06.png
+++ /dev/null
Binary files differ
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 27d0a245..29d5491c 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -69,22 +69,10 @@ ScreenRecoveryUI::ScreenRecoveryUI() :
69 menu_top(0), 69 menu_top(0),
70 menu_items(0), 70 menu_items(0),
71 menu_sel(0), 71 menu_sel(0),
72
73 // These values are correct for the default image resources
74 // provided with the android platform. Devices which use
75 // different resources should have a subclass of ScreenRecoveryUI
76 // that overrides Init() to set these values appropriately and
77 // then call the superclass Init().
78 animation_fps(20), 72 animation_fps(20),
79 indeterminate_frames(6), 73 installing_frames(-1),
80 installing_frames(7),
81 install_overlay_offset_x(13),
82 install_overlay_offset_y(190),
83 overlay_offset_x(-1),
84 overlay_offset_y(-1),
85 stage(-1), 74 stage(-1),
86 max_stage(-1) { 75 max_stage(-1) {
87
88 for (int i = 0; i < 5; i++) 76 for (int i = 0; i < 5; i++)
89 backgroundIcon[i] = NULL; 77 backgroundIcon[i] = NULL;
90 78
@@ -92,20 +80,6 @@ ScreenRecoveryUI::ScreenRecoveryUI() :
92 self = this; 80 self = this;
93} 81}
94 82
95// Draw the given frame over the installation overlay animation. The
96// background is not cleared or draw with the base icon first; we
97// assume that the frame already contains some other frame of the
98// animation. Does nothing if no overlay animation is defined.
99// Should only be called with updateMutex locked.
100void ScreenRecoveryUI::draw_install_overlay_locked(int frame) {
101 if (installationOverlay == NULL || overlay_offset_x < 0) return;
102 gr_surface surface = installationOverlay[frame];
103 int iconWidth = gr_get_width(surface);
104 int iconHeight = gr_get_height(surface);
105 gr_blit(surface, 0, 0, iconWidth, iconHeight,
106 overlay_offset_x, overlay_offset_y);
107}
108
109// Clear the screen and draw the currently selected background icon (if any). 83// Clear the screen and draw the currently selected background icon (if any).
110// Should only be called with updateMutex locked. 84// Should only be called with updateMutex locked.
111void ScreenRecoveryUI::draw_background_locked(Icon icon) 85void ScreenRecoveryUI::draw_background_locked(Icon icon)
@@ -116,6 +90,9 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon)
116 90
117 if (icon) { 91 if (icon) {
118 gr_surface surface = backgroundIcon[icon]; 92 gr_surface surface = backgroundIcon[icon];
93 if (icon == INSTALLING_UPDATE || icon == ERASING) {
94 surface = installation[installingFrame];
95 }
119 gr_surface text_surface = backgroundText[icon]; 96 gr_surface text_surface = backgroundText[icon];
120 97
121 int iconWidth = gr_get_width(surface); 98 int iconWidth = gr_get_width(surface);
@@ -126,13 +103,14 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon)
126 103
127 int sh = (max_stage >= 0) ? stageHeight : 0; 104 int sh = (max_stage >= 0) ? stageHeight : 0;
128 105
129 int iconX = (gr_fb_width() - iconWidth) / 2; 106 iconX = (gr_fb_width() - iconWidth) / 2;
130 int iconY = (gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2; 107 iconY = (gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2;
131 108
132 int textX = (gr_fb_width() - textWidth) / 2; 109 int textX = (gr_fb_width() - textWidth) / 2;
133 int textY = ((gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2) + iconHeight + 40; 110 int textY = ((gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2) + iconHeight + 40;
134 111
135 gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); 112 gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY);
113
136 if (stageHeight > 0) { 114 if (stageHeight > 0) {
137 int sw = gr_get_width(stageMarkerEmpty); 115 int sw = gr_get_width(stageMarkerEmpty);
138 int x = (gr_fb_width() - max_stage * gr_get_width(stageMarkerEmpty)) / 2; 116 int x = (gr_fb_width() - max_stage * gr_get_width(stageMarkerEmpty)) / 2;
@@ -144,10 +122,6 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon)
144 } 122 }
145 } 123 }
146 124
147 if (icon == INSTALLING_UPDATE || icon == ERASING) {
148 draw_install_overlay_locked(installingFrame);
149 }
150
151 gr_color(255, 255, 255, 255); 125 gr_color(255, 255, 255, 255);
152 gr_texticon(textX, textY, text_surface); 126 gr_texticon(textX, textY, text_surface);
153 } 127 }
@@ -160,7 +134,8 @@ void ScreenRecoveryUI::draw_progress_locked()
160 if (currentIcon == ERROR) return; 134 if (currentIcon == ERROR) return;
161 135
162 if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { 136 if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) {
163 draw_install_overlay_locked(installingFrame); 137 gr_surface icon = installation[installingFrame];
138 gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY);
164 } 139 }
165 140
166 if (progressBarType != EMPTY) { 141 if (progressBarType != EMPTY) {
@@ -197,18 +172,6 @@ void ScreenRecoveryUI::draw_progress_locked()
197 } 172 }
198 } 173 }
199 } 174 }
200
201 if (progressBarType == INDETERMINATE) {
202 static int frame = 0;
203 gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy);
204 // in RTL locales, we run the animation backwards, which
205 // makes the spinner spin the other way.
206 if (rtl_locale) {
207 frame = (frame + indeterminate_frames - 1) % indeterminate_frames;
208 } else {
209 frame = (frame + 1) % indeterminate_frames;
210 }
211 }
212 } 175 }
213} 176}
214 177
@@ -335,12 +298,6 @@ void ScreenRecoveryUI::progress_loop() {
335 redraw = 1; 298 redraw = 1;
336 } 299 }
337 300
338 // update the progress bar animation, if active
339 // skip this if we have a text overlay (too expensive to update)
340 if (progressBarType == INDETERMINATE && !show_text) {
341 redraw = 1;
342 }
343
344 // move the progress bar forward on timed intervals, if configured 301 // move the progress bar forward on timed intervals, if configured
345 int duration = progressScopeDuration; 302 int duration = progressScopeDuration;
346 if (progressBarType == DETERMINATE && duration > 0) { 303 if (progressBarType == DETERMINATE && duration > 0) {
@@ -371,6 +328,13 @@ void ScreenRecoveryUI::LoadBitmap(const char* filename, gr_surface* surface) {
371 } 328 }
372} 329}
373 330
331void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, gr_surface** surface) {
332 int result = res_create_multi_surface(filename, frames, surface);
333 if (result < 0) {
334 LOGE("missing bitmap %s\n(Code %d)\n", filename, result);
335 }
336}
337
374void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, gr_surface* surface) { 338void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, gr_surface* surface) {
375 int result = res_create_localized_surface(filename, surface); 339 int result = res_create_localized_surface(filename, surface);
376 if (result < 0) { 340 if (result < 0) {
@@ -392,7 +356,9 @@ void ScreenRecoveryUI::Init()
392 text_cols = gr_fb_width() / char_width; 356 text_cols = gr_fb_width() / char_width;
393 if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; 357 if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1;
394 358
395 LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]); 359 backgroundIcon[NONE] = NULL;
360 LoadBitmapArray("icon_installing", &installing_frames, &installation);
361 backgroundIcon[INSTALLING_UPDATE] = installing_frames ? installation[0] : NULL;
396 backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; 362 backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
397 LoadBitmap("icon_error", &backgroundIcon[ERROR]); 363 LoadBitmap("icon_error", &backgroundIcon[ERROR]);
398 backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; 364 backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];
@@ -407,31 +373,6 @@ void ScreenRecoveryUI::Init()
407 LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]); 373 LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]);
408 LoadLocalizedBitmap("error_text", &backgroundText[ERROR]); 374 LoadLocalizedBitmap("error_text", &backgroundText[ERROR]);
409 375
410 int i;
411
412 progressBarIndeterminate = (gr_surface*)malloc(indeterminate_frames *
413 sizeof(gr_surface));
414 for (i = 0; i < indeterminate_frames; ++i) {
415 char filename[40];
416 // "indeterminate01.png", "indeterminate02.png", ...
417 sprintf(filename, "indeterminate%02d", i+1);
418 LoadBitmap(filename, progressBarIndeterminate+i);
419 }
420
421 if (installing_frames > 0) {
422 installationOverlay = (gr_surface*)malloc(installing_frames *
423 sizeof(gr_surface));
424 for (i = 0; i < installing_frames; ++i) {
425 char filename[40];
426 // "icon_installing_overlay01.png",
427 // "icon_installing_overlay02.png", ...
428 sprintf(filename, "icon_installing_overlay%02d", i+1);
429 LoadBitmap(filename, installationOverlay+i);
430 }
431 } else {
432 installationOverlay = NULL;
433 }
434
435 pthread_create(&progress_t, NULL, progress_thread, NULL); 376 pthread_create(&progress_t, NULL, progress_thread, NULL);
436 377
437 RecoveryUI::Init(); 378 RecoveryUI::Init();
@@ -464,19 +405,6 @@ void ScreenRecoveryUI::SetBackground(Icon icon)
464{ 405{
465 pthread_mutex_lock(&updateMutex); 406 pthread_mutex_lock(&updateMutex);
466 407
467 // Adjust the offset to account for the positioning of the
468 // base image on the screen.
469 if (backgroundIcon[icon] != NULL) {
470 gr_surface bg = backgroundIcon[icon];
471 gr_surface text = backgroundText[icon];
472 overlay_offset_x = install_overlay_offset_x + (gr_fb_width() - gr_get_width(bg)) / 2;
473 overlay_offset_y = install_overlay_offset_y +
474 (gr_fb_height() - (gr_get_height(bg) +
475 gr_get_height(text) +
476 40 +
477 ((max_stage >= 0) ? gr_get_height(stageMarkerEmpty) : 0))) / 2;
478 }
479
480 currentIcon = icon; 408 currentIcon = icon;
481 update_screen_locked(); 409 update_screen_locked();
482 410
@@ -516,7 +444,7 @@ void ScreenRecoveryUI::SetProgress(float fraction)
516 if (fraction > 1.0) fraction = 1.0; 444 if (fraction > 1.0) fraction = 1.0;
517 if (progressBarType == DETERMINATE && fraction > progress) { 445 if (progressBarType == DETERMINATE && fraction > progress) {
518 // Skip updates that aren't visibly different. 446 // Skip updates that aren't visibly different.
519 int width = gr_get_width(progressBarIndeterminate[0]); 447 int width = gr_get_width(progressBarEmpty);
520 float scale = width * progressScopeSize; 448 float scale = width * progressScopeSize;
521 if ((int) (progress * scale) != (int) (fraction * scale)) { 449 if ((int) (progress * scale) != (int) (fraction * scale)) {
522 progress = fraction; 450 progress = fraction;
diff --git a/screen_ui.h b/screen_ui.h
index 5c4366d2..ea7712a3 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -68,8 +68,7 @@ class ScreenRecoveryUI : public RecoveryUI {
68 pthread_mutex_t updateMutex; 68 pthread_mutex_t updateMutex;
69 gr_surface backgroundIcon[5]; 69 gr_surface backgroundIcon[5];
70 gr_surface backgroundText[5]; 70 gr_surface backgroundText[5];
71 gr_surface *installationOverlay; 71 gr_surface *installation;
72 gr_surface *progressBarIndeterminate;
73 gr_surface progressBarEmpty; 72 gr_surface progressBarEmpty;
74 gr_surface progressBarFill; 73 gr_surface progressBarFill;
75 gr_surface stageMarkerEmpty; 74 gr_surface stageMarkerEmpty;
@@ -101,12 +100,9 @@ class ScreenRecoveryUI : public RecoveryUI {
101 pthread_t progress_t; 100 pthread_t progress_t;
102 101
103 int animation_fps; 102 int animation_fps;
104 int indeterminate_frames;
105 int installing_frames; 103 int installing_frames;
106 protected: 104
107 int install_overlay_offset_x, install_overlay_offset_y; 105 int iconX, iconY;
108 private:
109 int overlay_offset_x, overlay_offset_y;
110 106
111 int stage, max_stage; 107 int stage, max_stage;
112 108
@@ -120,6 +116,7 @@ class ScreenRecoveryUI : public RecoveryUI {
120 void progress_loop(); 116 void progress_loop();
121 117
122 void LoadBitmap(const char* filename, gr_surface* surface); 118 void LoadBitmap(const char* filename, gr_surface* surface);
119 void LoadBitmapArray(const char* filename, int* frames, gr_surface** surface);
123 void LoadLocalizedBitmap(const char* filename, gr_surface* surface); 120 void LoadLocalizedBitmap(const char* filename, gr_surface* surface);
124}; 121};
125 122