aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Bargiacchi2016-09-09 10:18:06 -0500
committerDamien Bargiacchi2016-09-09 10:22:49 -0500
commitad8b5a6c1195b94d8d80671e1bf791c32008fbef (patch)
tree44e738b6d19769809b69a69b76abbef239a36fab /wear_ui.cpp
parent43d186021a9fae0d2aa4e1a409fdb7132402db00 (diff)
downloadplatform-bootable-recovery-ad8b5a6c1195b94d8d80671e1bf791c32008fbef.tar.gz
platform-bootable-recovery-ad8b5a6c1195b94d8d80671e1bf791c32008fbef.tar.xz
platform-bootable-recovery-ad8b5a6c1195b94d8d80671e1bf791c32008fbef.zip
Remove duplicate thread loop
Fixes animation running at 2x speed Change-Id: Ieec353097b6eee1cf40530e6f4f1e69927d2bc98
Diffstat (limited to 'wear_ui.cpp')
-rw-r--r--wear_ui.cpp56
1 files changed, 4 insertions, 52 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp
index 3550992a..bfa7097e 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -184,55 +184,10 @@ void WearRecoveryUI::draw_screen_locked()
184 } 184 }
185} 185}
186 186
187// Keeps the progress bar updated, even when the process is otherwise busy. 187// TODO merge drawing routines with screen_ui
188void* WearRecoveryUI::progress_thread(void *cookie) { 188void WearRecoveryUI::update_progress_locked() {
189 self->progress_loop(); 189 draw_screen_locked();
190 return NULL; 190 gr_flip();
191}
192
193void WearRecoveryUI::progress_loop() {
194 double interval = 1.0 / animation_fps;
195 for (;;) {
196 double start = now();
197 pthread_mutex_lock(&updateMutex);
198 bool redraw = false;
199
200 if ((currentIcon == INSTALLING_UPDATE || currentIcon == ERASING)
201 && !show_text) {
202 if (!intro_done) {
203 if (current_frame >= intro_frames - 1) {
204 intro_done = true;
205 current_frame = 0;
206 } else {
207 current_frame++;
208 }
209 } else {
210 current_frame = (current_frame + 1) % loop_frames;
211 }
212 redraw = true;
213 }
214
215 // move the progress bar forward on timed intervals, if configured
216 int duration = progressScopeDuration;
217 if (progressBarType == DETERMINATE && duration > 0) {
218 double elapsed = now() - progressScopeTime;
219 float p = 1.0 * elapsed / duration;
220 if (p > 1.0) p = 1.0;
221 if (p > progress) {
222 progress = p;
223 redraw = true;
224 }
225 }
226
227 if (redraw) update_screen_locked();
228
229 pthread_mutex_unlock(&updateMutex);
230 double end = now();
231 // minimum of 20ms delay between frames
232 double delay = interval - (end-start);
233 if (delay < 0.02) delay = 0.02;
234 usleep((long)(delay * 1000000));
235 }
236} 191}
237 192
238void WearRecoveryUI::InitTextParams() { 193void WearRecoveryUI::InitTextParams() {
@@ -253,9 +208,6 @@ void WearRecoveryUI::Init() {
253 backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; 208 backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
254 LoadBitmap("icon_error", &backgroundIcon[ERROR]); 209 LoadBitmap("icon_error", &backgroundIcon[ERROR]);
255 backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; 210 backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];
256
257 pthread_create(&progress_t, NULL, progress_thread, NULL);
258
259} 211}
260 212
261void WearRecoveryUI::SetStage(int current, int max) 213void WearRecoveryUI::SetStage(int current, int max)