presentation-time-client-protocol.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. /* Generated by wayland-scanner 1.26.0 */
  2. #ifndef PRESENTATION_TIME_CLIENT_PROTOCOL_H
  3. #define PRESENTATION_TIME_CLIENT_PROTOCOL_H
  4. #include <stdint.h>
  5. #include <stddef.h>
  6. #include "wayland-client.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /**
  11. * @page page_presentation_time The presentation_time protocol
  12. * @section page_ifaces_presentation_time Interfaces
  13. * - @subpage page_iface_wp_presentation - timed presentation related wl_surface requests
  14. * - @subpage page_iface_wp_presentation_feedback - presentation time feedback event
  15. * @section page_copyright_presentation_time Copyright
  16. * <pre>
  17. *
  18. * Copyright © 2013-2014 Collabora, Ltd.
  19. *
  20. * Permission is hereby granted, free of charge, to any person obtaining a
  21. * copy of this software and associated documentation files (the "Software"),
  22. * to deal in the Software without restriction, including without limitation
  23. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  24. * and/or sell copies of the Software, and to permit persons to whom the
  25. * Software is furnished to do so, subject to the following conditions:
  26. *
  27. * The above copyright notice and this permission notice (including the next
  28. * paragraph) shall be included in all copies or substantial portions of the
  29. * Software.
  30. *
  31. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  33. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  34. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  35. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  36. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  37. * DEALINGS IN THE SOFTWARE.
  38. * </pre>
  39. */
  40. struct wl_output;
  41. struct wl_surface;
  42. struct wp_presentation;
  43. struct wp_presentation_feedback;
  44. #ifndef WP_PRESENTATION_INTERFACE
  45. #define WP_PRESENTATION_INTERFACE
  46. /**
  47. * @page page_iface_wp_presentation wp_presentation
  48. * @section page_iface_wp_presentation_desc Description
  49. *
  50. *
  51. *
  52. *
  53. * The main feature of this interface is accurate presentation
  54. * timing feedback to ensure smooth video playback while maintaining
  55. * audio/video synchronization. Some features use the concept of a
  56. * presentation clock, which is defined in the
  57. * presentation.clock_id event.
  58. *
  59. * A content update for a wl_surface is submitted by a
  60. * wl_surface.commit request. Request 'feedback' associates with
  61. * the wl_surface.commit and provides feedback on the content
  62. * update, particularly the final realized presentation time.
  63. *
  64. *
  65. *
  66. * When the final realized presentation time is available, e.g.
  67. * after a framebuffer flip completes, the requested
  68. * presentation_feedback.presented events are sent. The final
  69. * presentation time can differ from the compositor's predicted
  70. * display update time and the update's target time, especially
  71. * when the compositor misses its target vertical blanking period.
  72. * @section page_iface_wp_presentation_api API
  73. * See @ref iface_wp_presentation.
  74. */
  75. /**
  76. * @defgroup iface_wp_presentation The wp_presentation interface
  77. *
  78. *
  79. *
  80. *
  81. * The main feature of this interface is accurate presentation
  82. * timing feedback to ensure smooth video playback while maintaining
  83. * audio/video synchronization. Some features use the concept of a
  84. * presentation clock, which is defined in the
  85. * presentation.clock_id event.
  86. *
  87. * A content update for a wl_surface is submitted by a
  88. * wl_surface.commit request. Request 'feedback' associates with
  89. * the wl_surface.commit and provides feedback on the content
  90. * update, particularly the final realized presentation time.
  91. *
  92. *
  93. *
  94. * When the final realized presentation time is available, e.g.
  95. * after a framebuffer flip completes, the requested
  96. * presentation_feedback.presented events are sent. The final
  97. * presentation time can differ from the compositor's predicted
  98. * display update time and the update's target time, especially
  99. * when the compositor misses its target vertical blanking period.
  100. */
  101. extern const struct wl_interface wp_presentation_interface;
  102. #endif
  103. #ifndef WP_PRESENTATION_FEEDBACK_INTERFACE
  104. #define WP_PRESENTATION_FEEDBACK_INTERFACE
  105. /**
  106. * @page page_iface_wp_presentation_feedback wp_presentation_feedback
  107. * @section page_iface_wp_presentation_feedback_desc Description
  108. *
  109. * A presentation_feedback object returns an indication that a
  110. * wl_surface content update has become visible to the user.
  111. * One object corresponds to one content update submission
  112. * (wl_surface.commit). There are two possible outcomes: the
  113. * content update is presented to the user, and a presentation
  114. * timestamp delivered; or, the user did not see the content
  115. * update because it was superseded or its surface destroyed,
  116. * and the content update is discarded.
  117. *
  118. * Once a presentation_feedback object has delivered a 'presented'
  119. * or 'discarded' event it is automatically destroyed.
  120. * @section page_iface_wp_presentation_feedback_api API
  121. * See @ref iface_wp_presentation_feedback.
  122. */
  123. /**
  124. * @defgroup iface_wp_presentation_feedback The wp_presentation_feedback interface
  125. *
  126. * A presentation_feedback object returns an indication that a
  127. * wl_surface content update has become visible to the user.
  128. * One object corresponds to one content update submission
  129. * (wl_surface.commit). There are two possible outcomes: the
  130. * content update is presented to the user, and a presentation
  131. * timestamp delivered; or, the user did not see the content
  132. * update because it was superseded or its surface destroyed,
  133. * and the content update is discarded.
  134. *
  135. * Once a presentation_feedback object has delivered a 'presented'
  136. * or 'discarded' event it is automatically destroyed.
  137. */
  138. extern const struct wl_interface wp_presentation_feedback_interface;
  139. #endif
  140. #ifndef WP_PRESENTATION_ERROR_ENUM
  141. #define WP_PRESENTATION_ERROR_ENUM
  142. /**
  143. * @ingroup iface_wp_presentation
  144. * fatal presentation errors
  145. *
  146. * These fatal protocol errors may be emitted in response to
  147. * illegal presentation requests.
  148. */
  149. enum wp_presentation_error {
  150. /**
  151. * invalid value in tv_nsec
  152. */
  153. WP_PRESENTATION_ERROR_INVALID_TIMESTAMP = 0,
  154. /**
  155. * invalid flag
  156. */
  157. WP_PRESENTATION_ERROR_INVALID_FLAG = 1,
  158. };
  159. #endif /* WP_PRESENTATION_ERROR_ENUM */
  160. /**
  161. * @ingroup iface_wp_presentation
  162. * @struct wp_presentation_listener
  163. */
  164. struct wp_presentation_listener {
  165. /**
  166. * clock ID for timestamps
  167. *
  168. * This event tells the client in which clock domain the
  169. * compositor interprets the timestamps used by the presentation
  170. * extension. This clock is called the presentation clock.
  171. *
  172. * The compositor sends this event when the client binds to the
  173. * presentation interface. The presentation clock does not change
  174. * during the lifetime of the client connection.
  175. *
  176. * The clock identifier is platform dependent. On POSIX platforms,
  177. * the identifier value is one of the clockid_t values accepted by
  178. * clock_gettime(). clock_gettime() is defined by POSIX.1-2001.
  179. *
  180. * Timestamps in this clock domain are expressed as tv_sec_hi,
  181. * tv_sec_lo, tv_nsec triples, each component being an unsigned
  182. * 32-bit value. Whole seconds are in tv_sec which is a 64-bit
  183. * value combined from tv_sec_hi and tv_sec_lo, and the additional
  184. * fractional part in tv_nsec as nanoseconds. Hence, for valid
  185. * timestamps tv_nsec must be in [0, 999999999].
  186. *
  187. * Note that clock_id applies only to the presentation clock, and
  188. * implies nothing about e.g. the timestamps used in the Wayland
  189. * core protocol input events.
  190. *
  191. * Compositors should prefer a clock which does not jump and is not
  192. * slewed e.g. by NTP. The absolute value of the clock is
  193. * irrelevant. Precision of one millisecond or better is
  194. * recommended. Clients must be able to query the current clock
  195. * value directly, not by asking the compositor.
  196. * @param clk_id platform clock identifier
  197. */
  198. void (*clock_id)(void *data,
  199. struct wp_presentation *wp_presentation,
  200. uint32_t clk_id);
  201. };
  202. /**
  203. * @ingroup iface_wp_presentation
  204. */
  205. static inline int
  206. wp_presentation_add_listener(struct wp_presentation *wp_presentation,
  207. const struct wp_presentation_listener *listener, void *data)
  208. {
  209. return wl_proxy_add_listener((struct wl_proxy *) wp_presentation,
  210. (void (**)(void)) listener, data);
  211. }
  212. #define WP_PRESENTATION_DESTROY 0
  213. #define WP_PRESENTATION_FEEDBACK 1
  214. /**
  215. * @ingroup iface_wp_presentation
  216. */
  217. #define WP_PRESENTATION_CLOCK_ID_SINCE_VERSION 1
  218. /**
  219. * @ingroup iface_wp_presentation
  220. */
  221. #define WP_PRESENTATION_DESTROY_SINCE_VERSION 1
  222. /**
  223. * @ingroup iface_wp_presentation
  224. */
  225. #define WP_PRESENTATION_FEEDBACK_SINCE_VERSION 1
  226. /** @ingroup iface_wp_presentation */
  227. static inline void
  228. wp_presentation_set_user_data(struct wp_presentation *wp_presentation, void *user_data)
  229. {
  230. wl_proxy_set_user_data((struct wl_proxy *) wp_presentation, user_data);
  231. }
  232. /** @ingroup iface_wp_presentation */
  233. static inline void *
  234. wp_presentation_get_user_data(struct wp_presentation *wp_presentation)
  235. {
  236. return wl_proxy_get_user_data((struct wl_proxy *) wp_presentation);
  237. }
  238. static inline uint32_t
  239. wp_presentation_get_version(struct wp_presentation *wp_presentation)
  240. {
  241. return wl_proxy_get_version((struct wl_proxy *) wp_presentation);
  242. }
  243. /**
  244. * @ingroup iface_wp_presentation
  245. *
  246. * Informs the server that the client will no longer be using
  247. * this protocol object. Existing objects created by this object
  248. * are not affected.
  249. */
  250. static inline void
  251. wp_presentation_destroy(struct wp_presentation *wp_presentation)
  252. {
  253. wl_proxy_marshal_flags((struct wl_proxy *) wp_presentation,
  254. WP_PRESENTATION_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_presentation), WL_MARSHAL_FLAG_DESTROY);
  255. }
  256. /**
  257. * @ingroup iface_wp_presentation
  258. *
  259. * Request presentation feedback for the current content submission
  260. * on the given surface. This creates a new presentation_feedback
  261. * object, which will deliver the feedback information once. If
  262. * multiple presentation_feedback objects are created for the same
  263. * submission, they will all deliver the same information.
  264. *
  265. * For details on what information is returned, see the
  266. * presentation_feedback interface.
  267. */
  268. static inline struct wp_presentation_feedback *
  269. wp_presentation_feedback(struct wp_presentation *wp_presentation, struct wl_surface *surface)
  270. {
  271. struct wl_proxy *callback;
  272. callback = wl_proxy_marshal_flags((struct wl_proxy *) wp_presentation,
  273. WP_PRESENTATION_FEEDBACK, &wp_presentation_feedback_interface, wl_proxy_get_version((struct wl_proxy *) wp_presentation), 0, surface, NULL);
  274. return (struct wp_presentation_feedback *) callback;
  275. }
  276. #ifndef WP_PRESENTATION_FEEDBACK_KIND_ENUM
  277. #define WP_PRESENTATION_FEEDBACK_KIND_ENUM
  278. /**
  279. * @ingroup iface_wp_presentation_feedback
  280. * bitmask of flags in presented event
  281. *
  282. * These flags provide information about how the presentation of
  283. * the related content update was done. The intent is to help
  284. * clients assess the reliability of the feedback and the visual
  285. * quality with respect to possible tearing and timings.
  286. */
  287. enum wp_presentation_feedback_kind {
  288. /**
  289. * presentation was vsync'd
  290. *
  291. * The presentation was synchronized to the "vertical retrace" by
  292. * the display hardware such that tearing does not happen. Relying
  293. * on software scheduling is not acceptable for this flag. If
  294. * presentation is done by a copy to the active frontbuffer, then
  295. * it must guarantee that tearing cannot happen.
  296. */
  297. WP_PRESENTATION_FEEDBACK_KIND_VSYNC = 0x1,
  298. /**
  299. * hardware provided the presentation timestamp
  300. *
  301. * The display hardware provided measurements that the hardware
  302. * driver converted into a presentation timestamp. Sampling a clock
  303. * in software is not acceptable for this flag.
  304. */
  305. WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK = 0x2,
  306. /**
  307. * hardware signalled the start of the presentation
  308. *
  309. * The display hardware signalled that it started using the new
  310. * image content. The opposite of this is e.g. a timer being used
  311. * to guess when the display hardware has switched to the new image
  312. * content.
  313. */
  314. WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION = 0x4,
  315. /**
  316. * presentation was done zero-copy
  317. *
  318. * The presentation of this update was done zero-copy. This means
  319. * the buffer from the client was given to display hardware as is,
  320. * without copying it. Compositing with OpenGL counts as copying,
  321. * even if textured directly from the client buffer. Possible
  322. * zero-copy cases include direct scanout of a fullscreen surface
  323. * and a surface on a hardware overlay.
  324. */
  325. WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY = 0x8,
  326. };
  327. #endif /* WP_PRESENTATION_FEEDBACK_KIND_ENUM */
  328. /**
  329. * @ingroup iface_wp_presentation_feedback
  330. * @struct wp_presentation_feedback_listener
  331. */
  332. struct wp_presentation_feedback_listener {
  333. /**
  334. * presentation synchronized to this output
  335. *
  336. * As presentation can be synchronized to only one output at a
  337. * time, this event tells which output it was. This event is only
  338. * sent prior to the presented event.
  339. *
  340. * As clients may bind to the same global wl_output multiple times,
  341. * this event is sent for each bound instance that matches the
  342. * synchronized output. If a client has not bound to the right
  343. * wl_output global at all, this event is not sent.
  344. * @param output presentation output
  345. */
  346. void (*sync_output)(void *data,
  347. struct wp_presentation_feedback *wp_presentation_feedback,
  348. struct wl_output *output);
  349. /**
  350. * the content update was displayed
  351. *
  352. * The associated content update was displayed to the user at the
  353. * indicated time (tv_sec_hi/lo, tv_nsec). For the interpretation
  354. * of the timestamp, see presentation.clock_id event.
  355. *
  356. * The timestamp corresponds to the time when the content update
  357. * turned into light the first time on the surface's main output.
  358. * Compositors may approximate this from the framebuffer flip
  359. * completion events from the system, and the latency of the
  360. * physical display path if known.
  361. *
  362. * This event is preceded by all related sync_output events telling
  363. * which output's refresh cycle the feedback corresponds to, i.e.
  364. * the main output for the surface. Compositors are recommended to
  365. * choose the output containing the largest part of the wl_surface,
  366. * or keeping the output they previously chose. Having a stable
  367. * presentation output association helps clients predict future
  368. * output refreshes (vblank).
  369. *
  370. * The 'refresh' argument gives the compositor's prediction of how
  371. * many nanoseconds after tv_sec, tv_nsec the very next output
  372. * refresh may occur. This is to further aid clients in predicting
  373. * future refreshes, i.e., estimating the timestamps targeting the
  374. * next few vblanks. If such prediction cannot usefully be done,
  375. * the argument is zero.
  376. *
  377. * For version 2 and later, if the output does not have a constant
  378. * refresh rate, explicit video mode switches excluded, then the
  379. * refresh argument must be either an appropriate rate picked by
  380. * the compositor (e.g. fastest rate), or 0 if no such rate exists.
  381. * For version 1, if the output does not have a constant refresh
  382. * rate, the refresh argument must be zero.
  383. *
  384. * The 64-bit value combined from seq_hi and seq_lo is the value of
  385. * the output's vertical retrace counter when the content update
  386. * was first scanned out to the display. This value must be
  387. * compatible with the definition of MSC in GLX_OML_sync_control
  388. * specification. Note, that if the display path has a non-zero
  389. * latency, the time instant specified by this counter may differ
  390. * from the timestamp's.
  391. *
  392. * If the output does not have a concept of vertical retrace or a
  393. * refresh cycle, or the output device is self-refreshing without a
  394. * way to query the refresh count, then the arguments seq_hi and
  395. * seq_lo must be zero.
  396. * @param tv_sec_hi high 32 bits of the seconds part of the presentation timestamp
  397. * @param tv_sec_lo low 32 bits of the seconds part of the presentation timestamp
  398. * @param tv_nsec nanoseconds part of the presentation timestamp
  399. * @param refresh nanoseconds till next refresh
  400. * @param seq_hi high 32 bits of refresh counter
  401. * @param seq_lo low 32 bits of refresh counter
  402. * @param flags combination of 'kind' values
  403. */
  404. void (*presented)(void *data,
  405. struct wp_presentation_feedback *wp_presentation_feedback,
  406. uint32_t tv_sec_hi,
  407. uint32_t tv_sec_lo,
  408. uint32_t tv_nsec,
  409. uint32_t refresh,
  410. uint32_t seq_hi,
  411. uint32_t seq_lo,
  412. uint32_t flags);
  413. /**
  414. * the content update was not displayed
  415. *
  416. * The content update was never displayed to the user.
  417. */
  418. void (*discarded)(void *data,
  419. struct wp_presentation_feedback *wp_presentation_feedback);
  420. };
  421. /**
  422. * @ingroup iface_wp_presentation_feedback
  423. */
  424. static inline int
  425. wp_presentation_feedback_add_listener(struct wp_presentation_feedback *wp_presentation_feedback,
  426. const struct wp_presentation_feedback_listener *listener, void *data)
  427. {
  428. return wl_proxy_add_listener((struct wl_proxy *) wp_presentation_feedback,
  429. (void (**)(void)) listener, data);
  430. }
  431. /**
  432. * @ingroup iface_wp_presentation_feedback
  433. */
  434. #define WP_PRESENTATION_FEEDBACK_SYNC_OUTPUT_SINCE_VERSION 1
  435. /**
  436. * @ingroup iface_wp_presentation_feedback
  437. */
  438. #define WP_PRESENTATION_FEEDBACK_PRESENTED_SINCE_VERSION 1
  439. /**
  440. * @ingroup iface_wp_presentation_feedback
  441. */
  442. #define WP_PRESENTATION_FEEDBACK_DISCARDED_SINCE_VERSION 1
  443. /** @ingroup iface_wp_presentation_feedback */
  444. static inline void
  445. wp_presentation_feedback_set_user_data(struct wp_presentation_feedback *wp_presentation_feedback, void *user_data)
  446. {
  447. wl_proxy_set_user_data((struct wl_proxy *) wp_presentation_feedback, user_data);
  448. }
  449. /** @ingroup iface_wp_presentation_feedback */
  450. static inline void *
  451. wp_presentation_feedback_get_user_data(struct wp_presentation_feedback *wp_presentation_feedback)
  452. {
  453. return wl_proxy_get_user_data((struct wl_proxy *) wp_presentation_feedback);
  454. }
  455. static inline uint32_t
  456. wp_presentation_feedback_get_version(struct wp_presentation_feedback *wp_presentation_feedback)
  457. {
  458. return wl_proxy_get_version((struct wl_proxy *) wp_presentation_feedback);
  459. }
  460. /** @ingroup iface_wp_presentation_feedback */
  461. static inline void
  462. wp_presentation_feedback_destroy(struct wp_presentation_feedback *wp_presentation_feedback)
  463. {
  464. wl_proxy_destroy((struct wl_proxy *) wp_presentation_feedback);
  465. }
  466. #ifdef __cplusplus
  467. }
  468. #endif
  469. #endif