gdk4/auto/
frame_timings.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Holds timing information for a single frame of the application’s displays.
10    ///
11    /// To retrieve [`FrameTimings`][crate::FrameTimings] objects, use [`FrameClock::timings()`][crate::FrameClock::timings()]
12    /// or [`FrameClock::current_timings()`][crate::FrameClock::current_timings()]. The information in
13    /// [`FrameTimings`][crate::FrameTimings] is useful for precise synchronization of video with
14    /// the event or audio streams, and for measuring quality metrics for the
15    /// application’s display, such as latency and jitter.
16    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
17    pub struct FrameTimings(Shared<ffi::GdkFrameTimings>);
18
19    match fn {
20        ref => |ptr| ffi::gdk_frame_timings_ref(ptr),
21        unref => |ptr| ffi::gdk_frame_timings_unref(ptr),
22        type_ => || ffi::gdk_frame_timings_get_type(),
23    }
24}
25
26impl FrameTimings {
27    /// Returns whether @self are complete.
28    ///
29    /// The timing information in a [`FrameTimings`][crate::FrameTimings] is filled in
30    /// incrementally as the frame as drawn and passed off to the
31    /// window system for processing and display to the user. The
32    /// accessor functions for [`FrameTimings`][crate::FrameTimings] can return 0 to
33    /// indicate an unavailable value for two reasons: either because
34    /// the information is not yet available, or because it isn't
35    /// available at all.
36    ///
37    /// Once this function returns [`true`] for a frame, you can be
38    /// certain that no further values will become available and be
39    /// stored in the [`FrameTimings`][crate::FrameTimings].
40    ///
41    /// # Returns
42    ///
43    /// [`true`] if all information that will be available
44    ///   for the frame has been filled in.
45    #[doc(alias = "gdk_frame_timings_get_complete")]
46    #[doc(alias = "get_complete")]
47    pub fn is_complete(&self) -> bool {
48        unsafe { from_glib(ffi::gdk_frame_timings_get_complete(self.to_glib_none().0)) }
49    }
50
51    /// Gets the frame counter value of the [`FrameClock`][crate::FrameClock] when
52    /// this frame was drawn.
53    ///
54    /// # Returns
55    ///
56    /// the frame counter value for this frame
57    #[doc(alias = "gdk_frame_timings_get_frame_counter")]
58    #[doc(alias = "get_frame_counter")]
59    pub fn frame_counter(&self) -> i64 {
60        unsafe { ffi::gdk_frame_timings_get_frame_counter(self.to_glib_none().0) }
61    }
62
63    /// Returns the frame time for the frame.
64    ///
65    /// This is the time value that is typically used to time
66    /// animations for the frame. See [`FrameClock::frame_time()`][crate::FrameClock::frame_time()].
67    ///
68    /// # Returns
69    ///
70    /// the frame time for the frame, in the timescale
71    ///  of g_get_monotonic_time()
72    #[doc(alias = "gdk_frame_timings_get_frame_time")]
73    #[doc(alias = "get_frame_time")]
74    pub fn frame_time(&self) -> i64 {
75        unsafe { ffi::gdk_frame_timings_get_frame_time(self.to_glib_none().0) }
76    }
77
78    /// Gets the predicted time at which this frame will be displayed.
79    ///
80    /// Although no predicted time may be available, if one is available,
81    /// it will be available while the frame is being generated, in contrast
82    /// to [`presentation_time()`][Self::presentation_time()], which is only
83    /// available after the frame has been presented.
84    ///
85    /// In general, if you are simply animating, you should use
86    /// [`FrameClock::frame_time()`][crate::FrameClock::frame_time()] rather than this function,
87    /// but this function is useful for applications that want exact control
88    /// over latency. For example, a movie player may want this information
89    /// for Audio/Video synchronization.
90    ///
91    /// # Returns
92    ///
93    /// The predicted time at which the frame will be presented,
94    ///   in the timescale of g_get_monotonic_time(), or 0 if no predicted
95    ///   presentation time is available.
96    #[doc(alias = "gdk_frame_timings_get_predicted_presentation_time")]
97    #[doc(alias = "get_predicted_presentation_time")]
98    pub fn predicted_presentation_time(&self) -> i64 {
99        unsafe { ffi::gdk_frame_timings_get_predicted_presentation_time(self.to_glib_none().0) }
100    }
101
102    /// Reurns the presentation time.
103    ///
104    /// This is the time at which the frame became visible to the user.
105    ///
106    /// # Returns
107    ///
108    /// the time the frame was displayed to the user, in the
109    ///   timescale of g_get_monotonic_time(), or 0 if no presentation
110    ///   time is available. See [`is_complete()`][Self::is_complete()]
111    #[doc(alias = "gdk_frame_timings_get_presentation_time")]
112    #[doc(alias = "get_presentation_time")]
113    pub fn presentation_time(&self) -> i64 {
114        unsafe { ffi::gdk_frame_timings_get_presentation_time(self.to_glib_none().0) }
115    }
116
117    /// Gets the natural interval between presentation times for
118    /// the display that this frame was displayed on.
119    ///
120    /// Frame presentation usually happens during the “vertical
121    /// blanking interval”.
122    ///
123    /// # Returns
124    ///
125    /// the refresh interval of the display, in microseconds,
126    ///   or 0 if the refresh interval is not available.
127    ///   See [`is_complete()`][Self::is_complete()].
128    #[doc(alias = "gdk_frame_timings_get_refresh_interval")]
129    #[doc(alias = "get_refresh_interval")]
130    pub fn refresh_interval(&self) -> i64 {
131        unsafe { ffi::gdk_frame_timings_get_refresh_interval(self.to_glib_none().0) }
132    }
133}