| 334 | |
| 335 | #[no_mangle] |
| 336 | pub extern "C" fn bloom_begin_drawing() { |
| 337 | // Pace the game thread to target fps. Canvas refresh is driven by the |
| 338 | // frame counter change on the Swift side, so this sleep also controls |
| 339 | // apparent frame rate in the view. |
| 340 | let fps = state().target_fps.load(Ordering::Acquire); |
| 341 | if fps > 0 { |
| 342 | let frame_ns = 1_000_000_000u64 / fps as u64; |
| 343 | std::thread::sleep(std::time::Duration::from_nanos(frame_ns)); |
| 344 | } |
| 345 | draw_list::begin(); |
| 346 | } |
| 347 | |
| 348 | #[no_mangle] |
| 349 | pub extern "C" fn bloom_end_drawing() { |