present_priv.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * Copyright © 2013 Keith Packard
  3. *
  4. * Permission to use, copy, modify, distribute, and sell this software and its
  5. * documentation for any purpose is hereby granted without fee, provided that
  6. * the above copyright notice appear in all copies and that both that copyright
  7. * notice and this permission notice appear in supporting documentation, and
  8. * that the name of the copyright holders not be used in advertising or
  9. * publicity pertaining to distribution of the software without specific,
  10. * written prior permission. The copyright holders make no representations
  11. * about the suitability of this software for any purpose. It is provided "as
  12. * is" without express or implied warranty.
  13. *
  14. * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16. * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  19. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  20. * OF THIS SOFTWARE.
  21. */
  22. #ifndef _PRESENT_PRIV_H_
  23. #define _PRESENT_PRIV_H_
  24. #include <X11/X.h>
  25. #include "scrnintstr.h"
  26. #include "misc.h"
  27. #include "list.h"
  28. #include "windowstr.h"
  29. #include "dixstruct.h"
  30. #include "present.h"
  31. #include <syncsdk.h>
  32. #include <syncsrv.h>
  33. #include <xfixes.h>
  34. #include <randrstr.h>
  35. extern int present_request;
  36. extern DevPrivateKeyRec present_screen_private_key;
  37. typedef struct present_fence *present_fence_ptr;
  38. typedef struct present_notify present_notify_rec, *present_notify_ptr;
  39. struct present_notify {
  40. struct xorg_list window_list;
  41. WindowPtr window;
  42. CARD32 serial;
  43. };
  44. struct present_vblank {
  45. struct xorg_list window_list;
  46. struct xorg_list event_queue;
  47. ScreenPtr screen;
  48. WindowPtr window;
  49. PixmapPtr pixmap;
  50. RegionPtr valid;
  51. RegionPtr update;
  52. RRCrtcPtr crtc;
  53. uint32_t serial;
  54. int16_t x_off;
  55. int16_t y_off;
  56. CARD16 kind;
  57. uint64_t event_id;
  58. uint64_t target_msc;
  59. uint64_t msc_offset;
  60. present_fence_ptr idle_fence;
  61. present_fence_ptr wait_fence;
  62. present_notify_ptr notifies;
  63. int num_notifies;
  64. Bool queued; /* on present_exec_queue */
  65. Bool flip; /* planning on using flip */
  66. Bool flip_ready; /* wants to flip, but waiting for previous flip or unflip */
  67. Bool sync_flip; /* do flip synchronous to vblank */
  68. Bool abort_flip; /* aborting this flip */
  69. };
  70. typedef struct present_screen_priv {
  71. CloseScreenProcPtr CloseScreen;
  72. ConfigNotifyProcPtr ConfigNotify;
  73. DestroyWindowProcPtr DestroyWindow;
  74. ClipNotifyProcPtr ClipNotify;
  75. present_vblank_ptr flip_pending;
  76. uint64_t unflip_event_id;
  77. uint32_t fake_interval;
  78. /* Currently active flipped pixmap and fence */
  79. RRCrtcPtr flip_crtc;
  80. WindowPtr flip_window;
  81. uint32_t flip_serial;
  82. PixmapPtr flip_pixmap;
  83. present_fence_ptr flip_idle_fence;
  84. present_screen_info_ptr info;
  85. } present_screen_priv_rec, *present_screen_priv_ptr;
  86. #define wrap(priv,real,mem,func) {\
  87. priv->mem = real->mem; \
  88. real->mem = func; \
  89. }
  90. #define unwrap(priv,real,mem) {\
  91. real->mem = priv->mem; \
  92. }
  93. static inline present_screen_priv_ptr
  94. present_screen_priv(ScreenPtr screen)
  95. {
  96. return (present_screen_priv_ptr)dixLookupPrivate(&(screen)->devPrivates, &present_screen_private_key);
  97. }
  98. /*
  99. * Each window has a list of clients and event masks
  100. */
  101. typedef struct present_event *present_event_ptr;
  102. typedef struct present_event {
  103. present_event_ptr next;
  104. ClientPtr client;
  105. WindowPtr window;
  106. XID id;
  107. int mask;
  108. } present_event_rec;
  109. typedef struct present_window_priv {
  110. present_event_ptr events;
  111. RRCrtcPtr crtc; /* Last reported CRTC from get_ust_msc */
  112. uint64_t msc_offset;
  113. uint64_t msc; /* Last reported MSC from the current crtc */
  114. struct xorg_list vblank;
  115. struct xorg_list notifies;
  116. } present_window_priv_rec, *present_window_priv_ptr;
  117. extern DevPrivateKeyRec present_window_private_key;
  118. static inline present_window_priv_ptr
  119. present_window_priv(WindowPtr window)
  120. {
  121. return (present_window_priv_ptr)dixGetPrivate(&(window)->devPrivates, &present_window_private_key);
  122. }
  123. present_window_priv_ptr
  124. present_get_window_priv(WindowPtr window, Bool create);
  125. extern RESTYPE present_event_type;
  126. /*
  127. * present.c
  128. */
  129. int
  130. present_pixmap(WindowPtr window,
  131. PixmapPtr pixmap,
  132. CARD32 serial,
  133. RegionPtr valid,
  134. RegionPtr update,
  135. int16_t x_off,
  136. int16_t y_off,
  137. RRCrtcPtr target_crtc,
  138. SyncFence *wait_fence,
  139. SyncFence *idle_fence,
  140. uint32_t options,
  141. uint64_t target_msc,
  142. uint64_t divisor,
  143. uint64_t remainder,
  144. present_notify_ptr notifies,
  145. int num_notifies);
  146. int
  147. present_notify_msc(WindowPtr window,
  148. CARD32 serial,
  149. uint64_t target_msc,
  150. uint64_t divisor,
  151. uint64_t remainder);
  152. void
  153. present_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, uint64_t msc);
  154. void
  155. present_vblank_destroy(present_vblank_ptr vblank);
  156. void
  157. present_flip_destroy(ScreenPtr screen);
  158. void
  159. present_check_flip_window(WindowPtr window);
  160. RRCrtcPtr
  161. present_get_crtc(WindowPtr window);
  162. uint32_t
  163. present_query_capabilities(RRCrtcPtr crtc);
  164. Bool
  165. present_init(void);
  166. /*
  167. * present_event.c
  168. */
  169. void
  170. present_free_events(WindowPtr window);
  171. void
  172. present_send_config_notify(WindowPtr window, int x, int y, int w, int h, int bw, WindowPtr sibling);
  173. void
  174. present_send_complete_notify(WindowPtr window, CARD8 kind, CARD8 mode, CARD32 serial, uint64_t ust, uint64_t msc);
  175. void
  176. present_send_idle_notify(WindowPtr window, CARD32 serial, PixmapPtr pixmap, present_fence_ptr idle_fence);
  177. int
  178. present_select_input(ClientPtr client,
  179. CARD32 eid,
  180. WindowPtr window,
  181. CARD32 event_mask);
  182. Bool
  183. present_event_init(void);
  184. /*
  185. * present_fake.c
  186. */
  187. int
  188. present_fake_get_ust_msc(ScreenPtr screen, uint64_t *ust, uint64_t *msc);
  189. int
  190. present_fake_queue_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc);
  191. void
  192. present_fake_abort_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc);
  193. void
  194. present_fake_screen_init(ScreenPtr screen);
  195. void
  196. present_fake_queue_init(void);
  197. /*
  198. * present_fence.c
  199. */
  200. struct present_fence *
  201. present_fence_create(SyncFence *sync_fence);
  202. void
  203. present_fence_destroy(struct present_fence *present_fence);
  204. void
  205. present_fence_set_triggered(struct present_fence *present_fence);
  206. Bool
  207. present_fence_check_triggered(struct present_fence *present_fence);
  208. void
  209. present_fence_set_callback(struct present_fence *present_fence,
  210. void (*callback)(void *param),
  211. void *param);
  212. XID
  213. present_fence_id(struct present_fence *present_fence);
  214. /*
  215. * present_notify.c
  216. */
  217. void
  218. present_clear_window_notifies(WindowPtr window);
  219. void
  220. present_free_window_notify(present_notify_ptr notify);
  221. int
  222. present_add_window_notify(present_notify_ptr notify);
  223. int
  224. present_create_notifies(ClientPtr client, int num_notifies, xPresentNotify *x_notifies, present_notify_ptr *p_notifies);
  225. void
  226. present_destroy_notifies(present_notify_ptr notifies, int num_notifies);
  227. /*
  228. * present_redirect.c
  229. */
  230. WindowPtr
  231. present_redirect(ClientPtr client, WindowPtr target);
  232. /*
  233. * present_request.c
  234. */
  235. int
  236. proc_present_dispatch(ClientPtr client);
  237. int
  238. sproc_present_dispatch(ClientPtr client);
  239. /*
  240. * present_screen.c
  241. */
  242. #endif /* _PRESENT_PRIV_H_ */