1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = gdk3-GdkFrameClock.html 27 * outPack = gdk 28 * outFile = FrameClock 29 * strct = GdkFrameClock 30 * realStrct= 31 * ctorStrct= 32 * clss = FrameClock 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_frame_clock_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gdk.FrameTimings 47 * structWrap: 48 * - GdkFrameTimings* -> FrameTimings 49 * module aliases: 50 * local aliases: 51 * overrides: 52 */ 53 54 module gdk.FrameClock; 55 56 public import gtkc.gdktypes; 57 58 private import gtkc.gdk; 59 private import glib.ConstructionException; 60 private import gobject.ObjectG; 61 62 private import gdk.FrameTimings; 63 64 65 66 /** 67 * A GdkFrameClock tells the application when to update and repaint a 68 * window. This may be synced to the vertical refresh rate of the 69 * monitor, for example. Even when the frame clock uses a simple timer 70 * rather than a hardware-based vertical sync, the frame clock helps 71 * because it ensures everything paints at the same time (reducing the 72 * total number of frames). The frame clock can also automatically 73 * stop painting when it knows the frames will not be visible, or 74 * scale back animation framerates. 75 * 76 * GdkFrameClock is designed to be compatible with an OpenGL-based 77 * implementation or with mozRequestAnimationFrame in Firefox, 78 * for example. 79 * 80 * A frame clock is idle until someone requests a frame with 81 * gdk_frame_clock_request_phase(). At some later point that makes 82 * sense for the synchronization being implemented, the clock will 83 * process a frame and emit signals for each phase that has been 84 * requested. (See the signals of the GdkFrameClock class for 85 * documentation of the phases. GDK_FRAME_CLOCK_PHASE_UPDATE and the 86 * "update" signal are most interesting for application 87 * writers, and are used to update the animations, using the frame time 88 * given by gdk_frame_clock_get_frame_time(). 89 * 90 * The frame time is reported in microseconds and generally in the same 91 * timescale as g_get_monotonic_time(), however, it is not the same 92 * as g_get_monotonic_time(). The frame time does not advance during 93 * the time a frame is being painted, and outside of a frame, an attempt 94 * is made so that all calls to gdk_frame_clock_get_frame_time() that 95 * are called at a "similar" time get the same value. This means that 96 * if different animations are timed by looking at the difference in 97 * time between an initial value from gdk_frame_clock_get_frame_time() 98 * and the value inside the "update" signal of the clock, 99 * they will stay exactly synchronized. 100 */ 101 public class FrameClock 102 { 103 104 /** the main Gtk struct */ 105 protected GdkFrameClock* gdkFrameClock; 106 107 108 /** Get the main Gtk struct */ 109 public GdkFrameClock* getFrameClockStruct() 110 { 111 return gdkFrameClock; 112 } 113 114 115 /** the main Gtk struct as a void* */ 116 protected void* getStruct() 117 { 118 return cast(void*)gdkFrameClock; 119 } 120 121 /** 122 * Sets our main struct and passes it to the parent class 123 */ 124 public this (GdkFrameClock* gdkFrameClock) 125 { 126 this.gdkFrameClock = gdkFrameClock; 127 } 128 129 /** 130 */ 131 132 /** 133 * Gets the time that should currently be used for animations. Inside 134 * the processing of a frame, it's the time used to compute the 135 * animation position of everything in a frame. Outside of a frame, it's 136 * the time of the conceptual "previous frame," which may be either 137 * the actual previous frame time, or if that's too old, an updated 138 * time. 139 * Returns: a timestamp in microseconds, in the timescale of of g_get_monotonic_time(). Since 3.8 140 */ 141 public long getFrameTime() 142 { 143 // gint64 gdk_frame_clock_get_frame_time (GdkFrameClock *frame_clock); 144 return gdk_frame_clock_get_frame_time(gdkFrameClock); 145 } 146 147 /** 148 * Asks the frame clock to run a particular phase. The signal 149 * corresponding the requested phase will be emitted the next 150 * time the frame clock processes. Multiple calls to 151 * gdk_frame_clock_request_phase() will be combined together 152 * and only one frame processed. If you are displaying animated 153 * content and want to continually request the 154 * GDK_FRAME_CLOCK_PHASE_UPDATE phase for a period of time, 155 * you should use gdk_frame_clock_begin_updating() instead, since 156 * this allows GTK+ to adjust system parameters to get maximally 157 * smooth animations. 158 * Params: 159 * phase = the phase that is requested 160 * Since 3.8 161 */ 162 public void requestPhase(GdkFrameClockPhase phase) 163 { 164 // void gdk_frame_clock_request_phase (GdkFrameClock *frame_clock, GdkFrameClockPhase phase); 165 gdk_frame_clock_request_phase(gdkFrameClock, phase); 166 } 167 168 /** 169 * Starts updates for an animation. Until a matching call to 170 * gdk_frame_clock_end_updating() is made, the frame clock will continually 171 * request a new frame with the GDK_FRAME_CLOCK_PHASE_UPDATE phase. 172 * This function may be called multiple times and frames will be 173 * requested until gdk_frame_clock_end_updating() is called the same 174 * number of times. 175 */ 176 public void beginUpdating() 177 { 178 // void gdk_frame_clock_begin_updating (GdkFrameClock *frame_clock); 179 gdk_frame_clock_begin_updating(gdkFrameClock); 180 } 181 182 /** 183 * Stops updates for an animation. See the documentation for 184 * gdk_frame_clock_begin_updating(). 185 */ 186 public void endUpdating() 187 { 188 // void gdk_frame_clock_end_updating (GdkFrameClock *frame_clock); 189 gdk_frame_clock_end_updating(gdkFrameClock); 190 } 191 192 /** 193 * A GdkFrameClock maintains a 64-bit counter that increments for 194 * each frame drawn. 195 * Returns: inside frame processing, the value of the frame counter for the current frame. Outside of frame processing, the frame counter for the last frame. Since 3.8 196 */ 197 public long getFrameCounter() 198 { 199 // gint64 gdk_frame_clock_get_frame_counter (GdkFrameClock *frame_clock); 200 return gdk_frame_clock_get_frame_counter(gdkFrameClock); 201 } 202 203 /** 204 * GdkFrameClock internally keeps a history of GdkFrameTiming 205 * objects for recent frames that can be retrieved with 206 * gdk_frame_clock_get_timings(). The set of stored frames 207 * is the set from the counter values given by 208 * gdk_frame_clock_get_history_start() and 209 * gdk_frame_clock_get_frame_counter(), inclusive. 210 * Returns: the frame counter value for the oldest frame that is available in the internal frame history of the GdkFrameClock. Since 3.8 211 */ 212 public long getHistoryStart() 213 { 214 // gint64 gdk_frame_clock_get_history_start (GdkFrameClock *frame_clock); 215 return gdk_frame_clock_get_history_start(gdkFrameClock); 216 } 217 218 /** 219 * Retrieves a GdkFrameTimings object holding timing information 220 * for the current frame or a recent frame. The GdkFrameTimings 221 * object may not yet be complete: see gdk_frame_timings_get_complete(). 222 * Params: 223 * frameCounter = the frame counter value identifying the frame to 224 * be received. 225 * Returns: the GdkFrameTimings object for the specified frame, or NULL if it is not available. See gdk_frame_clock_get_history_start(). Since 3.8 226 */ 227 public FrameTimings getTimings(long frameCounter) 228 { 229 // GdkFrameTimings * gdk_frame_clock_get_timings (GdkFrameClock *frame_clock, gint64 frame_counter); 230 auto p = gdk_frame_clock_get_timings(gdkFrameClock, frameCounter); 231 232 if(p is null) 233 { 234 return null; 235 } 236 237 return ObjectG.getDObject!(FrameTimings)(cast(GdkFrameTimings*) p); 238 } 239 240 /** 241 * Gets the frame timings for the current frame. 242 * Returns: the GdkFrameTimings for the frame currently being processed, or even no frame is being processed, for the previous frame. Before any frames have been procesed, returns NULL. Since 3.8 243 */ 244 public FrameTimings getCurrentTimings() 245 { 246 // GdkFrameTimings * gdk_frame_clock_get_current_timings (GdkFrameClock *frame_clock); 247 auto p = gdk_frame_clock_get_current_timings(gdkFrameClock); 248 249 if(p is null) 250 { 251 return null; 252 } 253 254 return ObjectG.getDObject!(FrameTimings)(cast(GdkFrameTimings*) p); 255 } 256 257 /** 258 * Using the frame history stored in the frame clock, finds the last 259 * known presentation time and refresh interval, and assuming that 260 * presentation times are separated by the refresh interval, 261 * predicts a presentation time that is a multiple of the refresh 262 * interval after the last presentation time, and later than base_time. 263 * Params: 264 * baseTime = base time for determining a presentaton time 265 * refreshIntervalReturn = a location to store the determined refresh 266 * interval, or NULL. A default refresh interval of 1/60th of 267 * a second will be stored if no history is present. 268 * presentationTimeReturn = a location to store the next 269 * candidate presentation time after the given base time. 270 * 0 will be will be stored if no history is present. 271 * Since 3.8 272 */ 273 public void getRefreshInfo(long baseTime, out long refreshIntervalReturn, out long presentationTimeReturn) 274 { 275 // void gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock, gint64 base_time, gint64 *refresh_interval_return, gint64 *presentation_time_return); 276 gdk_frame_clock_get_refresh_info(gdkFrameClock, baseTime, &refreshIntervalReturn, &presentationTimeReturn); 277 } 278 }