servo_display_link/lib.rs
1pub mod ios;
2pub mod macos;
3
4// High level bindings are broken on arm64 macOS. Disabling until there's a solution.
5
6/*use thiserror::Error;
7use time_point::TimePoint;
8
9#[cfg(target_os = "ios")]
10use crate::ios::DisplayLink as PlatformDisplayLink;
11#[cfg(target_os = "macos")]
12use crate::macos::DisplayLink as PlatformDisplayLink;
13
14#[derive(Debug, Error)]
15pub enum PauseError {
16 #[error("already paused")]
17 AlreadyPaused,
18}
19
20#[derive(Debug, Error)]
21pub enum ResumeError {
22 #[error("already running")]
23 AlreadyRunning,
24}
25
26/// `DisplayLink` is a timer object used to synchronize drawing with the refresh rate of the
27/// display.
28#[derive(Debug)]
29pub struct DisplayLink(PlatformDisplayLink);
30
31impl DisplayLink {
32 /// Creates a new `DisplayLink` with a callback that will be invoked with the `TimePoint` the
33 /// screen will next refresh.
34 ///
35 /// The returned `DisplayLink` will be in a paused state. Returns `None` if a `DisplayLink`
36 /// could not be created.
37 ///
38 /// ## Panic
39 ///
40 /// If the callback panics, the process will be aborted.
41 pub fn new<F>(callback: F) -> Option<Self>
42 where
43 F: 'static + FnMut(TimePoint) + Send,
44 {
45 PlatformDisplayLink::new(callback).map(DisplayLink)
46 }
47
48 pub fn on_display<F>(display_id: u32, callback: F) -> Option<Self>
49 where
50 F: 'static + FnMut(TimePoint) + Send,
51 {
52 PlatformDisplayLink::on_display(display_id, callback).map(DisplayLink)
53 }
54
55 pub fn set_current_display(&mut self, display_id: u32) {
56 self.0.set_current_display(display_id)
57 }
58
59 /// Returns `true` if the `DisplayLink` is currently paused.
60 pub fn is_paused(&self) -> bool {
61 self.0.is_paused()
62 }
63
64 /// Pauses the `DisplayLink`.
65 ///
66 /// A paused `DisplayLink` will not invoke it's callback. On iOS, it is necessary to pause the
67 /// `DisplayLink` in response to events like backgrounding.
68 pub fn pause(&mut self) -> Result<(), PauseError> {
69 self.0.pause()
70 }
71
72 /// Resumes the `DisplayLink`.
73 pub fn resume(&mut self) -> Result<(), ResumeError> {
74 self.0.resume()
75 }
76}*/