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