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