Permalink
Browse files

[wiki] port progress bar to grifo API

Only useful for high compression datasets so that some activity is
seen during the slow decompression process.

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information...
1 parent ef2083a commit aeb9b1cf53437f5aaabf7d141fce026e310c15bc @hxw hxw committed Mar 23, 2011
Showing with 35 additions and 16 deletions.
  1. +3 −16 wiki/LzmaDec.c
  2. +31 −0 wiki/lcd_buf_draw.c
  3. +1 −0 wiki/lcd_buf_draw.h
View
@@ -138,8 +138,7 @@ static const Byte kLiteralNextStates[kNumStates * 2] =
#define ENABLE_PROGRESS 0
#endif
-#define MAX_LZMA_PROGRESS_COUNT 240
-extern void draw_progress_bar(int progressCount);
+extern void draw_progress_bar(int progressCount, int limit);
static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
{
@@ -163,14 +162,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
UInt32 range = p->range;
UInt32 code = p->code;
#if ENABLE_PROGRESS
- SizeT LzmaSizePerProgressUnit = 0;
- SizeT LzmaLastPos = 0;
- SizeT LzmaProgressCount = 0;
-
- LzmaSizePerProgressUnit = p->dicBufSize / MAX_LZMA_PROGRESS_COUNT;
- if (LzmaSizePerProgressUnit < 1)
- LzmaSizePerProgressUnit = 1;
- draw_progress_bar(0);
+ draw_progress_bar(0, 0);
#endif
do
{
@@ -432,12 +424,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
}
}
#if ENABLE_PROGRESS
- while (dicPos - LzmaLastPos >= LzmaSizePerProgressUnit)
- {
- LzmaLastPos += LzmaSizePerProgressUnit;
- LzmaProgressCount++;
- draw_progress_bar(LzmaProgressCount);
- }
+ draw_progress_bar(dicPos, limit);
#endif
}
while (dicPos < limit && buf < bufLimit);
View
@@ -3103,3 +3103,34 @@ int lcd_draw_get_cur_y_pos()
{
return lcd_draw_cur_y_pos;
}
+
+
+#if ENABLE_PROGRESS
+extern void draw_progress_bar(int progressCount, int limit)
+{
+ static int last_x = 0;
+ if (0 >= progressCount) {
+ lcd_colour_t save = lcd_set_colour(LCD_WHITE);
+ lcd_move_to(0, 1);
+ lcd_line_to(LCD_WIDTH - 1, 1);
+ lcd_move_to(0, 2);
+ lcd_line_to(LCD_WIDTH - 1, 2);
+ lcd_set_colour(save);
+ last_x = 0;
+ } else {
+ int x = LCD_WIDTH * progressCount / limit;
+ if (x >= LCD_WIDTH) {
+ x = LCD_WIDTH - 1;
+ }
+ if (x != last_x) {
+ last_x = x;
+ lcd_colour_t save = lcd_set_colour(LCD_BLACK);
+ lcd_move_to(0, 1);
+ lcd_line_to(x, 1);
+ lcd_move_to(0, 2);
+ lcd_line_to(x, 2);
+ lcd_set_colour(save);
+ }
+ }
+}
+#endif
View
@@ -336,4 +336,5 @@ bool lcd_draw_highlight(int start_x, int start_y, int end_x, int end_y,
int lcd_draw_get_cur_y_pos();
unsigned char *lcd_draw_get_cur_buffer();
void load_all_fonts();
+void draw_progress_bar(int progressCount, int limit);
#endif /* _LCD_BUF_DRAW_H */

0 comments on commit aeb9b1c

Please sign in to comment.