rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / x11 / libdga / src / draw_db.c
blob47ea603f468b5fcbdf1b31c9256df40333ba40d5
1 /* Copyright (c) 1993, 2015, Oracle and/or its affiliates. All rights reserved.
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
24 /*
25 ** draw_db.c - Drawable veneer for DGA window buffer control routines
28 #ifdef SERVER_DGA
29 #include <X11/Xlib.h>
30 #endif /* SERVER_DGA */
31 #include "dga_incls.h"
33 int
34 dga_draw_db_grab (Dga_drawable dgadraw, int nbuffers,
35 int (*vrtfunc)(Dga_drawable), u_int *vrtcounterp)
37 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
38 case DGA_DRAW_WINDOW: {
39 _Dga_window dgawin = (_Dga_window)dgadraw;
40 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
41 return (0);
43 return (dga_db_grab((Dga_window)dgawin, nbuffers, vrtfunc, vrtcounterp));
45 case DGA_DRAW_PIXMAP:
46 default:
47 return (0);
51 int
52 dga_draw_db_ungrab (Dga_drawable dgadraw)
54 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
55 case DGA_DRAW_WINDOW: {
56 _Dga_window dgawin = (_Dga_window)dgadraw;
57 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
58 return (0);
60 return (dga_db_ungrab((Dga_window)dgawin));
62 case DGA_DRAW_PIXMAP:
63 default:
64 return (0);
68 void
69 dga_draw_db_write (Dga_drawable dgadraw, int buffer,
70 int (*writefunc)(void*, Dga_drawable, int),
71 void *data)
73 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
74 case DGA_DRAW_WINDOW: {
75 _Dga_window dgawin = (_Dga_window)dgadraw;
76 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
77 break;
79 dga_db_write((Dga_window)dgawin, buffer, writefunc, data);
80 break;
82 case DGA_DRAW_PIXMAP:
83 break;
87 void
88 dga_draw_db_read (Dga_drawable dgadraw, int buffer,
89 int (*readfunc)(void*, Dga_drawable, int),
90 void *data)
92 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
93 case DGA_DRAW_WINDOW: {
94 _Dga_window dgawin = (_Dga_window)dgadraw;
95 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
96 break;
98 dga_db_read((Dga_window)dgawin, buffer, readfunc, data);
99 break;
101 case DGA_DRAW_PIXMAP:
102 break;
106 void
107 dga_draw_db_display (Dga_drawable dgadraw, int buffer,
108 int (*visfunc)(void*, Dga_drawable, int),
109 void *data)
111 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
112 case DGA_DRAW_WINDOW: {
113 _Dga_window dgawin = (_Dga_window)dgadraw;
114 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
115 break;
117 dga_db_display((Dga_window)dgawin, buffer, visfunc, data);
118 break;
120 case DGA_DRAW_PIXMAP:
121 break;
125 void
126 dga_draw_db_interval (Dga_drawable dgadraw, int interval)
128 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
129 case DGA_DRAW_WINDOW: {
130 _Dga_window dgawin = (_Dga_window)dgadraw;
131 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
132 break;
134 dga_db_interval((Dga_window)dgawin, interval);
135 break;
137 case DGA_DRAW_PIXMAP:
138 break;
142 void
143 dga_draw_db_interval_wait (Dga_drawable dgadraw)
145 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
146 case DGA_DRAW_WINDOW: {
147 _Dga_window dgawin = (_Dga_window)dgadraw;
148 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
149 break;
151 dga_db_interval_wait((Dga_window)dgawin);
152 break;
154 case DGA_DRAW_PIXMAP:
155 break;
160 dga_draw_db_interval_check (Dga_drawable dgadraw)
162 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
163 case DGA_DRAW_WINDOW: {
164 _Dga_window dgawin = (_Dga_window)dgadraw;
165 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
166 /* not applicable to multibuffers - consider interval always expired */
167 return (1);
169 return (dga_db_interval_check((Dga_window)dgawin));
171 case DGA_DRAW_PIXMAP:
172 default:
173 /* not applicable to pixmaps - consider interval always expired */
174 return (1);
179 dga_draw_db_write_inquire (Dga_drawable dgadraw)
181 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
182 case DGA_DRAW_WINDOW: {
183 _Dga_window dgawin = (_Dga_window)dgadraw;
184 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
185 /* not applicable to multibuffers - always return an invalid buffer index */
186 return (-1);
188 return (dga_db_write_inquire((Dga_window)dgawin));
190 case DGA_DRAW_PIXMAP:
191 default:
192 /* not applicable to pixmaps - always return an invalid buffer index */
193 return (-1);
198 dga_draw_db_read_inquire (Dga_drawable dgadraw)
200 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
201 case DGA_DRAW_WINDOW: {
202 _Dga_window dgawin = (_Dga_window)dgadraw;
203 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
204 /* not applicable to multibuffers - always return an invalid buffer index */
205 return (-1);
207 return (dga_db_read_inquire((Dga_window)dgawin));
209 case DGA_DRAW_PIXMAP:
210 default:
211 /* not applicable to pixmaps - always return an invalid buffer index */
212 return (-1);
217 dga_draw_db_display_inquire (Dga_drawable dgadraw)
219 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
220 case DGA_DRAW_WINDOW: {
221 _Dga_window dgawin = (_Dga_window)dgadraw;
222 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
223 /* not applicable to multibuffers - always return an invalid buffer index */
224 return (-1);
226 return (dga_db_display_inquire((Dga_window)dgawin));
228 case DGA_DRAW_PIXMAP:
229 default:
230 /* not applicable to pixmaps - always return an invalid buffer index */
231 return (-1);
236 dga_draw_db_display_done (Dga_drawable dgadraw, int flag,
237 int (*display_done_func)(Dga_drawable))
239 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
240 case DGA_DRAW_WINDOW: {
241 _Dga_window dgawin = (_Dga_window)dgadraw;
242 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
243 /* not applicable to multibuffers - consider display done (to prevent hangs) */
244 return (1);
246 return (dga_db_display_done((Dga_window)dgawin, flag, display_done_func));
248 case DGA_DRAW_PIXMAP:
249 default:
250 /* not applicable to pixmaps - consider display done (to prevent hangs) */
251 return (1);
255 Dga_dbinfo *
256 dga_draw_db_dbinfop (Dga_drawable dgadraw)
258 switch ( ((_Dga_drawable)dgadraw)->drawable_type) {
259 case DGA_DRAW_WINDOW: {
260 _Dga_window dgawin = (_Dga_window)dgadraw;
261 if (!DGA_LOCKSUBJ_WINDOW(dgawin, dgawin->eLockSubj)) {
262 /* not applicable to multibuffers - return NULL */
263 return (NULL);
265 return (dga_win_dbinfop((Dga_window)dgawin));
267 case DGA_DRAW_PIXMAP:
268 default:
269 /* not applicable to pixmaps - return NULL */
270 return (NULL);