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