viewporter-server-protocol.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. /* Generated by wayland-scanner 1.26.0 */
  2. #ifndef VIEWPORTER_SERVER_PROTOCOL_H
  3. #define VIEWPORTER_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_viewporter The viewporter protocol
  14. * @section page_ifaces_viewporter Interfaces
  15. * - @subpage page_iface_wp_viewporter - surface cropping and scaling
  16. * - @subpage page_iface_wp_viewport - crop and scale interface to a wl_surface
  17. * @section page_copyright_viewporter Copyright
  18. * <pre>
  19. *
  20. * Copyright © 2013-2016 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_surface;
  43. struct wp_viewport;
  44. struct wp_viewporter;
  45. #ifndef WP_VIEWPORTER_INTERFACE
  46. #define WP_VIEWPORTER_INTERFACE
  47. /**
  48. * @page page_iface_wp_viewporter wp_viewporter
  49. * @section page_iface_wp_viewporter_desc Description
  50. *
  51. * The global interface exposing surface cropping and scaling
  52. * capabilities is used to instantiate an interface extension for a
  53. * wl_surface object. This extended interface will then allow
  54. * cropping and scaling the surface contents, effectively
  55. * disconnecting the direct relationship between the buffer and the
  56. * surface size.
  57. * @section page_iface_wp_viewporter_api API
  58. * See @ref iface_wp_viewporter.
  59. */
  60. /**
  61. * @defgroup iface_wp_viewporter The wp_viewporter interface
  62. *
  63. * The global interface exposing surface cropping and scaling
  64. * capabilities is used to instantiate an interface extension for a
  65. * wl_surface object. This extended interface will then allow
  66. * cropping and scaling the surface contents, effectively
  67. * disconnecting the direct relationship between the buffer and the
  68. * surface size.
  69. */
  70. extern const struct wl_interface wp_viewporter_interface;
  71. #endif
  72. #ifndef WP_VIEWPORT_INTERFACE
  73. #define WP_VIEWPORT_INTERFACE
  74. /**
  75. * @page page_iface_wp_viewport wp_viewport
  76. * @section page_iface_wp_viewport_desc Description
  77. *
  78. * An additional interface to a wl_surface object, which allows the
  79. * client to specify the cropping and scaling of the surface
  80. * contents.
  81. *
  82. * This interface works with two concepts: the source rectangle (src_x,
  83. * src_y, src_width, src_height), and the destination size (dst_width,
  84. * dst_height). The contents of the source rectangle are scaled to the
  85. * destination size, and content outside the source rectangle is ignored.
  86. * This state is double-buffered, see wl_surface.commit.
  87. *
  88. * The two parts of crop and scale state are independent: the source
  89. * rectangle, and the destination size. Initially both are unset, that
  90. * is, no scaling is applied. The whole of the current wl_buffer is
  91. * used as the source, and the surface size is as defined in
  92. * wl_surface.attach.
  93. *
  94. * If the destination size is set, it causes the surface size to become
  95. * dst_width, dst_height. The source (rectangle) is scaled to exactly
  96. * this size. This overrides whatever the attached wl_buffer size is,
  97. * unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
  98. * has no content and therefore no size. Otherwise, the size is always
  99. * at least 1x1 in surface local coordinates.
  100. *
  101. * If the source rectangle is set, it defines what area of the wl_buffer is
  102. * taken as the source. If the source rectangle is set and the destination
  103. * size is not set, then src_width and src_height must be integers, and the
  104. * surface size becomes the source rectangle size. This results in cropping
  105. * without scaling. If src_width or src_height are not integers and
  106. * destination size is not set, the bad_size protocol error is raised when
  107. * the surface state is applied.
  108. *
  109. * The coordinate transformations from buffer pixel coordinates up to
  110. * the surface-local coordinates happen in the following order:
  111. * 1. buffer_transform (wl_surface.set_buffer_transform)
  112. * 2. buffer_scale (wl_surface.set_buffer_scale)
  113. * 3. crop and scale (wp_viewport.set*)
  114. * This means, that the source rectangle coordinates of crop and scale
  115. * are given in the coordinates after the buffer transform and scale,
  116. * i.e. in the coordinates that would be the surface-local coordinates
  117. * if the crop and scale was not applied.
  118. *
  119. * If src_x or src_y are negative, the bad_value protocol error is raised.
  120. * Otherwise, if the source rectangle is partially or completely outside of
  121. * the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
  122. * when the surface state is applied. A NULL wl_buffer does not raise the
  123. * out_of_buffer error.
  124. *
  125. * If the wl_surface associated with the wp_viewport is destroyed,
  126. * all wp_viewport requests except 'destroy' raise the protocol error
  127. * no_surface.
  128. *
  129. * If the wp_viewport object is destroyed, the crop and scale
  130. * state is removed from the wl_surface. The change will be applied
  131. * on the next wl_surface.commit.
  132. * @section page_iface_wp_viewport_api API
  133. * See @ref iface_wp_viewport.
  134. */
  135. /**
  136. * @defgroup iface_wp_viewport The wp_viewport interface
  137. *
  138. * An additional interface to a wl_surface object, which allows the
  139. * client to specify the cropping and scaling of the surface
  140. * contents.
  141. *
  142. * This interface works with two concepts: the source rectangle (src_x,
  143. * src_y, src_width, src_height), and the destination size (dst_width,
  144. * dst_height). The contents of the source rectangle are scaled to the
  145. * destination size, and content outside the source rectangle is ignored.
  146. * This state is double-buffered, see wl_surface.commit.
  147. *
  148. * The two parts of crop and scale state are independent: the source
  149. * rectangle, and the destination size. Initially both are unset, that
  150. * is, no scaling is applied. The whole of the current wl_buffer is
  151. * used as the source, and the surface size is as defined in
  152. * wl_surface.attach.
  153. *
  154. * If the destination size is set, it causes the surface size to become
  155. * dst_width, dst_height. The source (rectangle) is scaled to exactly
  156. * this size. This overrides whatever the attached wl_buffer size is,
  157. * unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
  158. * has no content and therefore no size. Otherwise, the size is always
  159. * at least 1x1 in surface local coordinates.
  160. *
  161. * If the source rectangle is set, it defines what area of the wl_buffer is
  162. * taken as the source. If the source rectangle is set and the destination
  163. * size is not set, then src_width and src_height must be integers, and the
  164. * surface size becomes the source rectangle size. This results in cropping
  165. * without scaling. If src_width or src_height are not integers and
  166. * destination size is not set, the bad_size protocol error is raised when
  167. * the surface state is applied.
  168. *
  169. * The coordinate transformations from buffer pixel coordinates up to
  170. * the surface-local coordinates happen in the following order:
  171. * 1. buffer_transform (wl_surface.set_buffer_transform)
  172. * 2. buffer_scale (wl_surface.set_buffer_scale)
  173. * 3. crop and scale (wp_viewport.set*)
  174. * This means, that the source rectangle coordinates of crop and scale
  175. * are given in the coordinates after the buffer transform and scale,
  176. * i.e. in the coordinates that would be the surface-local coordinates
  177. * if the crop and scale was not applied.
  178. *
  179. * If src_x or src_y are negative, the bad_value protocol error is raised.
  180. * Otherwise, if the source rectangle is partially or completely outside of
  181. * the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
  182. * when the surface state is applied. A NULL wl_buffer does not raise the
  183. * out_of_buffer error.
  184. *
  185. * If the wl_surface associated with the wp_viewport is destroyed,
  186. * all wp_viewport requests except 'destroy' raise the protocol error
  187. * no_surface.
  188. *
  189. * If the wp_viewport object is destroyed, the crop and scale
  190. * state is removed from the wl_surface. The change will be applied
  191. * on the next wl_surface.commit.
  192. */
  193. extern const struct wl_interface wp_viewport_interface;
  194. #endif
  195. #ifndef WP_VIEWPORTER_ERROR_ENUM
  196. #define WP_VIEWPORTER_ERROR_ENUM
  197. enum wp_viewporter_error {
  198. /**
  199. * the surface already has a viewport object associated
  200. */
  201. WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS = 0,
  202. };
  203. #endif /* WP_VIEWPORTER_ERROR_ENUM */
  204. #ifndef WP_VIEWPORTER_ERROR_ENUM_IS_VALID
  205. #define WP_VIEWPORTER_ERROR_ENUM_IS_VALID
  206. /**
  207. * @ingroup iface_wp_viewporter
  208. * Validate a wp_viewporter error value.
  209. *
  210. * @return true on success, false on error.
  211. * @ref wp_viewporter_error
  212. */
  213. static inline bool
  214. wp_viewporter_error_is_valid(uint32_t value, uint32_t version) {
  215. switch (value) {
  216. case WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS:
  217. return version >= 1;
  218. default:
  219. return false;
  220. }
  221. }
  222. #endif /* WP_VIEWPORTER_ERROR_ENUM_IS_VALID */
  223. /**
  224. * @ingroup iface_wp_viewporter
  225. * @struct wp_viewporter_interface
  226. */
  227. struct wp_viewporter_interface {
  228. /**
  229. * unbind from the cropping and scaling interface
  230. *
  231. * Informs the server that the client will not be using this
  232. * protocol object anymore. This does not affect any other objects,
  233. * wp_viewport objects included.
  234. */
  235. void (*destroy)(struct wl_client *client,
  236. struct wl_resource *resource);
  237. /**
  238. * extend surface interface for crop and scale
  239. *
  240. * Instantiate an interface extension for the given wl_surface to
  241. * crop and scale its content. If the given wl_surface already has
  242. * a wp_viewport object associated, the viewport_exists protocol
  243. * error is raised.
  244. * @param id the new viewport interface id
  245. * @param surface the surface
  246. */
  247. void (*get_viewport)(struct wl_client *client,
  248. struct wl_resource *resource,
  249. uint32_t id,
  250. struct wl_resource *surface);
  251. };
  252. /**
  253. * @ingroup iface_wp_viewporter
  254. */
  255. #define WP_VIEWPORTER_DESTROY_SINCE_VERSION 1
  256. /**
  257. * @ingroup iface_wp_viewporter
  258. */
  259. #define WP_VIEWPORTER_GET_VIEWPORT_SINCE_VERSION 1
  260. #ifndef WP_VIEWPORT_ERROR_ENUM
  261. #define WP_VIEWPORT_ERROR_ENUM
  262. enum wp_viewport_error {
  263. /**
  264. * negative or zero values in width or height
  265. */
  266. WP_VIEWPORT_ERROR_BAD_VALUE = 0,
  267. /**
  268. * destination size is not integer
  269. */
  270. WP_VIEWPORT_ERROR_BAD_SIZE = 1,
  271. /**
  272. * source rectangle extends outside of the content area
  273. */
  274. WP_VIEWPORT_ERROR_OUT_OF_BUFFER = 2,
  275. /**
  276. * the wl_surface was destroyed
  277. */
  278. WP_VIEWPORT_ERROR_NO_SURFACE = 3,
  279. };
  280. #endif /* WP_VIEWPORT_ERROR_ENUM */
  281. #ifndef WP_VIEWPORT_ERROR_ENUM_IS_VALID
  282. #define WP_VIEWPORT_ERROR_ENUM_IS_VALID
  283. /**
  284. * @ingroup iface_wp_viewport
  285. * Validate a wp_viewport error value.
  286. *
  287. * @return true on success, false on error.
  288. * @ref wp_viewport_error
  289. */
  290. static inline bool
  291. wp_viewport_error_is_valid(uint32_t value, uint32_t version) {
  292. switch (value) {
  293. case WP_VIEWPORT_ERROR_BAD_VALUE:
  294. return version >= 1;
  295. case WP_VIEWPORT_ERROR_BAD_SIZE:
  296. return version >= 1;
  297. case WP_VIEWPORT_ERROR_OUT_OF_BUFFER:
  298. return version >= 1;
  299. case WP_VIEWPORT_ERROR_NO_SURFACE:
  300. return version >= 1;
  301. default:
  302. return false;
  303. }
  304. }
  305. #endif /* WP_VIEWPORT_ERROR_ENUM_IS_VALID */
  306. /**
  307. * @ingroup iface_wp_viewport
  308. * @struct wp_viewport_interface
  309. */
  310. struct wp_viewport_interface {
  311. /**
  312. * remove scaling and cropping from the surface
  313. *
  314. * The associated wl_surface's crop and scale state is removed.
  315. * The change is applied on the next wl_surface.commit.
  316. */
  317. void (*destroy)(struct wl_client *client,
  318. struct wl_resource *resource);
  319. /**
  320. * set the source rectangle for cropping
  321. *
  322. * Set the source rectangle of the associated wl_surface. See
  323. * wp_viewport for the description, and relation to the wl_buffer
  324. * size.
  325. *
  326. * If all of x, y, width and height are -1.0, the source rectangle
  327. * is unset instead. Any other set of values where width or height
  328. * are zero or negative, or x or y are negative, raise the
  329. * bad_value protocol error.
  330. *
  331. * The crop and scale state is double-buffered, see
  332. * wl_surface.commit.
  333. * @param x source rectangle x
  334. * @param y source rectangle y
  335. * @param width source rectangle width
  336. * @param height source rectangle height
  337. */
  338. void (*set_source)(struct wl_client *client,
  339. struct wl_resource *resource,
  340. wl_fixed_t x,
  341. wl_fixed_t y,
  342. wl_fixed_t width,
  343. wl_fixed_t height);
  344. /**
  345. * set the surface size for scaling
  346. *
  347. * Set the destination size of the associated wl_surface. See
  348. * wp_viewport for the description, and relation to the wl_buffer
  349. * size.
  350. *
  351. * If width is -1 and height is -1, the destination size is unset
  352. * instead. Any other pair of values for width and height that
  353. * contains zero or negative values raises the bad_value protocol
  354. * error.
  355. *
  356. * The crop and scale state is double-buffered, see
  357. * wl_surface.commit.
  358. * @param width surface width
  359. * @param height surface height
  360. */
  361. void (*set_destination)(struct wl_client *client,
  362. struct wl_resource *resource,
  363. int32_t width,
  364. int32_t height);
  365. };
  366. /**
  367. * @ingroup iface_wp_viewport
  368. */
  369. #define WP_VIEWPORT_DESTROY_SINCE_VERSION 1
  370. /**
  371. * @ingroup iface_wp_viewport
  372. */
  373. #define WP_VIEWPORT_SET_SOURCE_SINCE_VERSION 1
  374. /**
  375. * @ingroup iface_wp_viewport
  376. */
  377. #define WP_VIEWPORT_SET_DESTINATION_SINCE_VERSION 1
  378. #ifdef __cplusplus
  379. }
  380. #endif
  381. #endif