1
0

presentation-time-server-protocol.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /* Generated by wayland-scanner 1.26.0 */
  2. #ifndef PRESENTATION_TIME_SERVER_PROTOCOL_H
  3. #define PRESENTATION_TIME_SERVER_PROTOCOL_H
  4. #include <stdint.h>
  5. #include <stddef.h>
  6. #include "wayland-server.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. struct wl_client;
  11. struct wl_resource;
  12. /**
  13. * @page page_presentation_time The presentation_time protocol
  14. * @section page_ifaces_presentation_time Interfaces
  15. * - @subpage page_iface_wp_presentation - timed presentation related wl_surface requests
  16. * - @subpage page_iface_wp_presentation_feedback - presentation time feedback event
  17. * @section page_copyright_presentation_time Copyright
  18. * <pre>
  19. *
  20. * Copyright © 2013-2014 Collabora, Ltd.
  21. *
  22. * Permission is hereby granted, free of charge, to any person obtaining a
  23. * copy of this software and associated documentation files (the "Software"),
  24. * to deal in the Software without restriction, including without limitation
  25. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  26. * and/or sell copies of the Software, and to permit persons to whom the
  27. * Software is furnished to do so, subject to the following conditions:
  28. *
  29. * The above copyright notice and this permission notice (including the next
  30. * paragraph) shall be included in all copies or substantial portions of the
  31. * Software.
  32. *
  33. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  34. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  35. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  36. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  37. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  38. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  39. * DEALINGS IN THE SOFTWARE.
  40. * </pre>
  41. */
  42. struct wl_output;
  43. struct wl_surface;
  44. struct wp_presentation;
  45. struct wp_presentation_feedback;
  46. #ifndef WP_PRESENTATION_INTERFACE
  47. #define WP_PRESENTATION_INTERFACE
  48. /**
  49. * @page page_iface_wp_presentation wp_presentation
  50. * @section page_iface_wp_presentation_desc Description
  51. *
  52. *
  53. *
  54. *
  55. * The main feature of this interface is accurate presentation
  56. * timing feedback to ensure smooth video playback while maintaining
  57. * audio/video synchronization. Some features use the concept of a
  58. * presentation clock, which is defined in the
  59. * presentation.clock_id event.
  60. *
  61. * A content update for a wl_surface is submitted by a
  62. * wl_surface.commit request. Request 'feedback' associates with
  63. * the wl_surface.commit and provides feedback on the content
  64. * update, particularly the final realized presentation time.
  65. *
  66. *
  67. *
  68. * When the final realized presentation time is available, e.g.
  69. * after a framebuffer flip completes, the requested
  70. * presentation_feedback.presented events are sent. The final
  71. * presentation time can differ from the compositor's predicted
  72. * display update time and the update's target time, especially
  73. * when the compositor misses its target vertical blanking period.
  74. * @section page_iface_wp_presentation_api API
  75. * See @ref iface_wp_presentation.
  76. */
  77. /**
  78. * @defgroup iface_wp_presentation The wp_presentation interface
  79. *
  80. *
  81. *
  82. *
  83. * The main feature of this interface is accurate presentation
  84. * timing feedback to ensure smooth video playback while maintaining
  85. * audio/video synchronization. Some features use the concept of a
  86. * presentation clock, which is defined in the
  87. * presentation.clock_id event.
  88. *
  89. * A content update for a wl_surface is submitted by a
  90. * wl_surface.commit request. Request 'feedback' associates with
  91. * the wl_surface.commit and provides feedback on the content
  92. * update, particularly the final realized presentation time.
  93. *
  94. *
  95. *
  96. * When the final realized presentation time is available, e.g.
  97. * after a framebuffer flip completes, the requested
  98. * presentation_feedback.presented events are sent. The final
  99. * presentation time can differ from the compositor's predicted
  100. * display update time and the update's target time, especially
  101. * when the compositor misses its target vertical blanking period.
  102. */
  103. extern const struct wl_interface wp_presentation_interface;
  104. #endif
  105. #ifndef WP_PRESENTATION_FEEDBACK_INTERFACE
  106. #define WP_PRESENTATION_FEEDBACK_INTERFACE
  107. /**
  108. * @page page_iface_wp_presentation_feedback wp_presentation_feedback
  109. * @section page_iface_wp_presentation_feedback_desc Description
  110. *
  111. * A presentation_feedback object returns an indication that a
  112. * wl_surface content update has become visible to the user.
  113. * One object corresponds to one content update submission
  114. * (wl_surface.commit). There are two possible outcomes: the
  115. * content update is presented to the user, and a presentation
  116. * timestamp delivered; or, the user did not see the content
  117. * update because it was superseded or its surface destroyed,
  118. * and the content update is discarded.
  119. *
  120. * Once a presentation_feedback object has delivered a 'presented'
  121. * or 'discarded' event it is automatically destroyed.
  122. * @section page_iface_wp_presentation_feedback_api API
  123. * See @ref iface_wp_presentation_feedback.
  124. */
  125. /**
  126. * @defgroup iface_wp_presentation_feedback The wp_presentation_feedback interface
  127. *
  128. * A presentation_feedback object returns an indication that a
  129. * wl_surface content update has become visible to the user.
  130. * One object corresponds to one content update submission
  131. * (wl_surface.commit). There are two possible outcomes: the
  132. * content update is presented to the user, and a presentation
  133. * timestamp delivered; or, the user did not see the content
  134. * update because it was superseded or its surface destroyed,
  135. * and the content update is discarded.
  136. *
  137. * Once a presentation_feedback object has delivered a 'presented'
  138. * or 'discarded' event it is automatically destroyed.
  139. */
  140. extern const struct wl_interface wp_presentation_feedback_interface;
  141. #endif
  142. #ifndef WP_PRESENTATION_ERROR_ENUM
  143. #define WP_PRESENTATION_ERROR_ENUM
  144. /**
  145. * @ingroup iface_wp_presentation
  146. * fatal presentation errors
  147. *
  148. * These fatal protocol errors may be emitted in response to
  149. * illegal presentation requests.
  150. */
  151. enum wp_presentation_error {
  152. /**
  153. * invalid value in tv_nsec
  154. */
  155. WP_PRESENTATION_ERROR_INVALID_TIMESTAMP = 0,
  156. /**
  157. * invalid flag
  158. */
  159. WP_PRESENTATION_ERROR_INVALID_FLAG = 1,
  160. };
  161. #endif /* WP_PRESENTATION_ERROR_ENUM */
  162. #ifndef WP_PRESENTATION_ERROR_ENUM_IS_VALID
  163. #define WP_PRESENTATION_ERROR_ENUM_IS_VALID
  164. /**
  165. * @ingroup iface_wp_presentation
  166. * Validate a wp_presentation error value.
  167. *
  168. * @return true on success, false on error.
  169. * @ref wp_presentation_error
  170. */
  171. static inline bool
  172. wp_presentation_error_is_valid(uint32_t value, uint32_t version) {
  173. switch (value) {
  174. case WP_PRESENTATION_ERROR_INVALID_TIMESTAMP:
  175. return version >= 1;
  176. case WP_PRESENTATION_ERROR_INVALID_FLAG:
  177. return version >= 1;
  178. default:
  179. return false;
  180. }
  181. }
  182. #endif /* WP_PRESENTATION_ERROR_ENUM_IS_VALID */
  183. /**
  184. * @ingroup iface_wp_presentation
  185. * @struct wp_presentation_interface
  186. */
  187. struct wp_presentation_interface {
  188. /**
  189. * unbind from the presentation interface
  190. *
  191. * Informs the server that the client will no longer be using
  192. * this protocol object. Existing objects created by this object
  193. * are not affected.
  194. */
  195. void (*destroy)(struct wl_client *client,
  196. struct wl_resource *resource);
  197. /**
  198. * request presentation feedback information
  199. *
  200. * Request presentation feedback for the current content
  201. * submission on the given surface. This creates a new
  202. * presentation_feedback object, which will deliver the feedback
  203. * information once. If multiple presentation_feedback objects are
  204. * created for the same submission, they will all deliver the same
  205. * information.
  206. *
  207. * For details on what information is returned, see the
  208. * presentation_feedback interface.
  209. * @param surface target surface
  210. * @param callback new feedback object
  211. */
  212. void (*feedback)(struct wl_client *client,
  213. struct wl_resource *resource,
  214. struct wl_resource *surface,
  215. uint32_t callback);
  216. };
  217. #define WP_PRESENTATION_CLOCK_ID 0
  218. /**
  219. * @ingroup iface_wp_presentation
  220. */
  221. #define WP_PRESENTATION_CLOCK_ID_SINCE_VERSION 1
  222. /**
  223. * @ingroup iface_wp_presentation
  224. */
  225. #define WP_PRESENTATION_DESTROY_SINCE_VERSION 1
  226. /**
  227. * @ingroup iface_wp_presentation
  228. */
  229. #define WP_PRESENTATION_FEEDBACK_SINCE_VERSION 1
  230. /**
  231. * @ingroup iface_wp_presentation
  232. * Sends an clock_id event to the client owning the resource.
  233. * @param resource_ The client's resource
  234. * @param clk_id platform clock identifier
  235. */
  236. static inline void
  237. wp_presentation_send_clock_id(struct wl_resource *resource_, uint32_t clk_id)
  238. {
  239. wl_resource_post_event(resource_, WP_PRESENTATION_CLOCK_ID, clk_id);
  240. }
  241. #ifndef WP_PRESENTATION_FEEDBACK_KIND_ENUM
  242. #define WP_PRESENTATION_FEEDBACK_KIND_ENUM
  243. /**
  244. * @ingroup iface_wp_presentation_feedback
  245. * bitmask of flags in presented event
  246. *
  247. * These flags provide information about how the presentation of
  248. * the related content update was done. The intent is to help
  249. * clients assess the reliability of the feedback and the visual
  250. * quality with respect to possible tearing and timings.
  251. */
  252. enum wp_presentation_feedback_kind {
  253. /**
  254. * presentation was vsync'd
  255. *
  256. * The presentation was synchronized to the "vertical retrace" by
  257. * the display hardware such that tearing does not happen. Relying
  258. * on software scheduling is not acceptable for this flag. If
  259. * presentation is done by a copy to the active frontbuffer, then
  260. * it must guarantee that tearing cannot happen.
  261. */
  262. WP_PRESENTATION_FEEDBACK_KIND_VSYNC = 0x1,
  263. /**
  264. * hardware provided the presentation timestamp
  265. *
  266. * The display hardware provided measurements that the hardware
  267. * driver converted into a presentation timestamp. Sampling a clock
  268. * in software is not acceptable for this flag.
  269. */
  270. WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK = 0x2,
  271. /**
  272. * hardware signalled the start of the presentation
  273. *
  274. * The display hardware signalled that it started using the new
  275. * image content. The opposite of this is e.g. a timer being used
  276. * to guess when the display hardware has switched to the new image
  277. * content.
  278. */
  279. WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION = 0x4,
  280. /**
  281. * presentation was done zero-copy
  282. *
  283. * The presentation of this update was done zero-copy. This means
  284. * the buffer from the client was given to display hardware as is,
  285. * without copying it. Compositing with OpenGL counts as copying,
  286. * even if textured directly from the client buffer. Possible
  287. * zero-copy cases include direct scanout of a fullscreen surface
  288. * and a surface on a hardware overlay.
  289. */
  290. WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY = 0x8,
  291. };
  292. #endif /* WP_PRESENTATION_FEEDBACK_KIND_ENUM */
  293. #ifndef WP_PRESENTATION_FEEDBACK_KIND_ENUM_IS_VALID
  294. #define WP_PRESENTATION_FEEDBACK_KIND_ENUM_IS_VALID
  295. /**
  296. * @ingroup iface_wp_presentation_feedback
  297. * Validate a wp_presentation_feedback kind value.
  298. *
  299. * @return true on success, false on error.
  300. * @ref wp_presentation_feedback_kind
  301. */
  302. static inline bool
  303. wp_presentation_feedback_kind_is_valid(uint32_t value, uint32_t version) {
  304. uint32_t valid = 0;
  305. if (version >= 1)
  306. valid |= WP_PRESENTATION_FEEDBACK_KIND_VSYNC;
  307. if (version >= 1)
  308. valid |= WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
  309. if (version >= 1)
  310. valid |= WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION;
  311. if (version >= 1)
  312. valid |= WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY;
  313. return (value & ~valid) == 0;
  314. }
  315. #endif /* WP_PRESENTATION_FEEDBACK_KIND_ENUM_IS_VALID */
  316. #define WP_PRESENTATION_FEEDBACK_SYNC_OUTPUT 0
  317. #define WP_PRESENTATION_FEEDBACK_PRESENTED 1
  318. #define WP_PRESENTATION_FEEDBACK_DISCARDED 2
  319. /**
  320. * @ingroup iface_wp_presentation_feedback
  321. */
  322. #define WP_PRESENTATION_FEEDBACK_SYNC_OUTPUT_SINCE_VERSION 1
  323. /**
  324. * @ingroup iface_wp_presentation_feedback
  325. */
  326. #define WP_PRESENTATION_FEEDBACK_PRESENTED_SINCE_VERSION 1
  327. /**
  328. * @ingroup iface_wp_presentation_feedback
  329. */
  330. #define WP_PRESENTATION_FEEDBACK_DISCARDED_SINCE_VERSION 1
  331. /**
  332. * @ingroup iface_wp_presentation_feedback
  333. * Sends an sync_output event to the client owning the resource.
  334. * @param resource_ The client's resource
  335. * @param output presentation output
  336. */
  337. static inline void
  338. wp_presentation_feedback_send_sync_output(struct wl_resource *resource_, struct wl_resource *output)
  339. {
  340. wl_resource_post_event(resource_, WP_PRESENTATION_FEEDBACK_SYNC_OUTPUT, output);
  341. }
  342. /**
  343. * @ingroup iface_wp_presentation_feedback
  344. * Sends an presented event to the client owning the resource.
  345. * @param resource_ The client's resource
  346. * @param tv_sec_hi high 32 bits of the seconds part of the presentation timestamp
  347. * @param tv_sec_lo low 32 bits of the seconds part of the presentation timestamp
  348. * @param tv_nsec nanoseconds part of the presentation timestamp
  349. * @param refresh nanoseconds till next refresh
  350. * @param seq_hi high 32 bits of refresh counter
  351. * @param seq_lo low 32 bits of refresh counter
  352. * @param flags combination of 'kind' values
  353. */
  354. static inline void
  355. wp_presentation_feedback_send_presented(struct wl_resource *resource_, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags)
  356. {
  357. wl_resource_post_event(resource_, WP_PRESENTATION_FEEDBACK_PRESENTED, tv_sec_hi, tv_sec_lo, tv_nsec, refresh, seq_hi, seq_lo, flags);
  358. }
  359. /**
  360. * @ingroup iface_wp_presentation_feedback
  361. * Sends an discarded event to the client owning the resource.
  362. * @param resource_ The client's resource
  363. */
  364. static inline void
  365. wp_presentation_feedback_send_discarded(struct wl_resource *resource_)
  366. {
  367. wl_resource_post_event(resource_, WP_PRESENTATION_FEEDBACK_DISCARDED);
  368. }
  369. #ifdef __cplusplus
  370. }
  371. #endif
  372. #endif