Skip to content

Commit 09fa863

Browse files
committed
WIP: feat: implement frame timing
Make frame_scheduler able to time frames, e.g. tell flutter when to start rendering a frame when it receives a frame request. For now, this just unconditionally replies with the current time, i.e. starts rendering the frame immediately.
1 parent 23d39c2 commit 09fa863

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/frame_scheduler.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,17 @@ void frame_scheduler_on_fl_vsync_request(struct frame_scheduler *scheduler, intp
9595
//
9696

9797
/// TODO: Implement
98-
/// For now, just unconditionally reply
98+
/// For now, just unconditionally reply with the current time and a 60FPS frame interval.
9999
if (scheduler->present_mode == kTripleBufferedVsync_PresentMode) {
100-
scheduler->vsync_cb(scheduler->userdata, vsync_baton, 0, 0);
100+
uint64_t now = get_monotonic_time();
101+
uint64_t now_plus_frame_interval = now + 1000000000/60;
102+
scheduler->vsync_cb(scheduler->userdata, vsync_baton, now, now_plus_frame_interval);
101103
} else if (scheduler->present_mode == kDoubleBufferedVsync_PresentMode) {
102-
scheduler->vsync_cb(scheduler->userdata, vsync_baton, 0, 0);
104+
uint64_t now = get_monotonic_time();
105+
uint64_t now_plus_frame_interval = now + 1000000000/60;
106+
scheduler->vsync_cb(scheduler->userdata, vsync_baton, now, now_plus_frame_interval);
107+
} else {
108+
UNREACHABLE();
103109
}
104110
}
105111

0 commit comments

Comments
 (0)