present.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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_H_
  23. #define _PRESENT_H_
  24. #include <X11/extensions/presentproto.h>
  25. #include "randrstr.h"
  26. #include "presentext.h"
  27. typedef struct present_vblank present_vblank_rec, *present_vblank_ptr;
  28. /* Return the current CRTC for 'window'.
  29. */
  30. typedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window);
  31. /* Return the current ust/msc for 'crtc'
  32. */
  33. typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc);
  34. /* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 'event_id'
  35. * at or after 'msc'. Return false if it didn't happen (which might occur if 'crtc'
  36. * is not currently generating vblanks).
  37. */
  38. typedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc,
  39. uint64_t event_id,
  40. uint64_t msc);
  41. /* Abort pending vblank. The extension is no longer interested in
  42. * 'event_id' which was to be notified at 'msc'. If possible, the
  43. * driver is free to de-queue the notification.
  44. */
  45. typedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, uint64_t msc);
  46. /* Flush pending drawing on 'window' to the hardware.
  47. */
  48. typedef void (*present_flush_ptr) (WindowPtr window);
  49. /* Check if 'pixmap' is suitable for flipping to 'window'.
  50. */
  51. typedef Bool (*present_check_flip_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip);
  52. /* Flip pixmap, return false if it didn't happen.
  53. *
  54. * 'crtc' is to be used for any necessary synchronization.
  55. *
  56. * 'sync_flip' requests that the flip be performed at the next
  57. * vertical blank interval to avoid tearing artifacts. If false, the
  58. * flip should be performed as soon as possible.
  59. *
  60. * present_event_notify should be called with 'event_id' when the flip
  61. * occurs
  62. */
  63. typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
  64. uint64_t event_id,
  65. uint64_t target_msc,
  66. PixmapPtr pixmap,
  67. Bool sync_flip);
  68. /* "unflip" back to the regular screen scanout buffer
  69. *
  70. * present_event_notify should be called with 'event_id' when the unflip occurs.
  71. */
  72. typedef void (*present_unflip_ptr) (ScreenPtr screen,
  73. uint64_t event_id);
  74. #define PRESENT_SCREEN_INFO_VERSION 0
  75. typedef struct present_screen_info {
  76. uint32_t version;
  77. present_get_crtc_ptr get_crtc;
  78. present_get_ust_msc_ptr get_ust_msc;
  79. present_queue_vblank_ptr queue_vblank;
  80. present_abort_vblank_ptr abort_vblank;
  81. present_flush_ptr flush;
  82. uint32_t capabilities;
  83. present_check_flip_ptr check_flip;
  84. present_flip_ptr flip;
  85. present_unflip_ptr unflip;
  86. } present_screen_info_rec, *present_screen_info_ptr;
  87. /*
  88. * Called when 'event_id' occurs. 'ust' and 'msc' indicate when the
  89. * event actually happened
  90. */
  91. extern _X_EXPORT void
  92. present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc);
  93. /* 'crtc' has been turned off, so any pending events will never occur.
  94. */
  95. extern _X_EXPORT void
  96. present_event_abandon(RRCrtcPtr crtc);
  97. extern _X_EXPORT Bool
  98. present_screen_init(ScreenPtr screen, present_screen_info_ptr info);
  99. typedef void (*present_complete_notify_proc)(WindowPtr window,
  100. CARD8 mode,
  101. CARD32 serial,
  102. uint64_t ust,
  103. uint64_t msc);
  104. extern _X_EXPORT void
  105. present_register_complete_notify(present_complete_notify_proc proc);
  106. #endif /* _PRESENT_H_ */