Keep download gesture scheduling on the drawing thread
This commit is contained in:
1 parent
c2d4fd11d8
commit
5e439147a8
3 files changed
+37
-2
No files matched your search
@@ -18,6 +18,8 @@ FrameActivitySample :: struct {
|
||||
|
||||
frame_activity_state: FrameActivityState;
|
||||
frame_pacing_state: FramePacing;
|
||||
frame_work_activity: FrameActivityState;
|
||||
frame_work_deferred: bool;
|
||||
|
||||
ACTIVE_GRACE_FRAMES :: 12
|
||||
|
||||
@@ -25,6 +27,15 @@ ACTIVE_GRACE_FRAMES :: 12
|
||||
FramePacingReset :: () {
|
||||
frame_activity_state = FrameActivityState.{}
|
||||
frame_pacing_state = FramePacing.{}
|
||||
frame_work_activity = FrameActivityState.{}
|
||||
frame_work_deferred = false
|
||||
}
|
||||
|
||||
// Owned by the drawing thread, independently of Android's background sync
|
||||
// timer. A focused field or an animation alone never holds downloads back.
|
||||
#program_export
|
||||
AppBackgroundWorkDeferred :: () -> bool {
|
||||
return frame_work_deferred
|
||||
}
|
||||
|
||||
PracticeFrameActive :: (screen: s32) -> bool {
|
||||
@@ -34,6 +45,10 @@ PracticeFrameActive :: (screen: s32) -> bool {
|
||||
#program_export
|
||||
app_update_frame_pacing :: (app: *InnerBreeze,
|
||||
sample: FrameActivitySample) -> FramePacingDecision {
|
||||
work := FrameActivityStep(frame_work_activity, 0, 0,
|
||||
sample.pointer_active || sample.keyboard_active, false, ACTIVE_GRACE_FRAMES)
|
||||
frame_work_activity = work.state
|
||||
frame_work_deferred = work.active
|
||||
engaged: bool = false
|
||||
if app != null {
|
||||
// A practice running in its small window animates at full rate too.
|
||||
|
||||
@@ -385,8 +385,8 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
if CellsLumiOpen() {
|
||||
app_lumi_pump(app)
|
||||
}
|
||||
app_sync_record_input(app, GetTime())
|
||||
defer_packages := app_sync_user_idle(app, GetTime()) == 0 ||
|
||||
defer_packages := AppBackgroundWorkDeferred() || app.ui.pointer_active ||
|
||||
app.ui.keyboard_active ||
|
||||
app.ui.route_transition_active || app.ui.route_transition_pending
|
||||
PackagePump(app.enabled_apps, cast(s32)PackageNow(), defer_packages)
|
||||
NodeAppsPump(cast(s32)PackageNow(), app.launcher_open, defer_packages)
|
||||
|
||||
@@ -103,5 +103,25 @@ main(void)
|
||||
decision = app_update_frame_pacing(&app, sample);
|
||||
}
|
||||
assert(decision.state.target_fps == 15);
|
||||
/* A gesture defers package installation. Keeping a field focused or
|
||||
animating afterward never prevents the transfer from being installed. */
|
||||
FramePacingReset();
|
||||
sample.pointer_active = true;
|
||||
app_update_frame_pacing(&app, sample);
|
||||
assert(AppBackgroundWorkDeferred());
|
||||
sample.pointer_active = false;
|
||||
sample.text_input_active = true;
|
||||
guide_animating = true;
|
||||
for (int frame = 0; frame < 12; frame++) {
|
||||
app_update_frame_pacing(&app, sample);
|
||||
assert(AppBackgroundWorkDeferred());
|
||||
}
|
||||
app_update_frame_pacing(&app, sample);
|
||||
assert(!AppBackgroundWorkDeferred());
|
||||
sample.keyboard_active = true;
|
||||
app_update_frame_pacing(&app, sample);
|
||||
assert(AppBackgroundWorkDeferred());
|
||||
FramePacingReset();
|
||||
assert(!AppBackgroundWorkDeferred());
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user