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
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.
25 ** draw_db.c - Drawable veneer for DGA window buffer control routines
30 #endif /* SERVER_DGA */
31 #include "dga_incls.h"
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
)) {
43 return (dga_db_grab((Dga_window
)dgawin
, nbuffers
, vrtfunc
, vrtcounterp
));
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
)) {
60 return (dga_db_ungrab((Dga_window
)dgawin
));
69 dga_draw_db_write (Dga_drawable dgadraw
, int buffer
,
70 int (*writefunc
)(void*, Dga_drawable
, int),
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
)) {
79 dga_db_write((Dga_window
)dgawin
, buffer
, writefunc
, data
);
88 dga_draw_db_read (Dga_drawable dgadraw
, int buffer
,
89 int (*readfunc
)(void*, Dga_drawable
, int),
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
)) {
98 dga_db_read((Dga_window
)dgawin
, buffer
, readfunc
, data
);
101 case DGA_DRAW_PIXMAP
:
107 dga_draw_db_display (Dga_drawable dgadraw
, int buffer
,
108 int (*visfunc
)(void*, Dga_drawable
, int),
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
)) {
117 dga_db_display((Dga_window
)dgawin
, buffer
, visfunc
, data
);
120 case DGA_DRAW_PIXMAP
:
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
)) {
134 dga_db_interval((Dga_window
)dgawin
, interval
);
137 case DGA_DRAW_PIXMAP
:
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
)) {
151 dga_db_interval_wait((Dga_window
)dgawin
);
154 case DGA_DRAW_PIXMAP
:
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 */
169 return (dga_db_interval_check((Dga_window
)dgawin
));
171 case DGA_DRAW_PIXMAP
:
173 /* not applicable to pixmaps - consider interval always expired */
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 */
188 return (dga_db_write_inquire((Dga_window
)dgawin
));
190 case DGA_DRAW_PIXMAP
:
192 /* not applicable to pixmaps - always return an invalid buffer index */
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 */
207 return (dga_db_read_inquire((Dga_window
)dgawin
));
209 case DGA_DRAW_PIXMAP
:
211 /* not applicable to pixmaps - always return an invalid buffer index */
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 */
226 return (dga_db_display_inquire((Dga_window
)dgawin
));
228 case DGA_DRAW_PIXMAP
:
230 /* not applicable to pixmaps - always return an invalid buffer index */
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) */
246 return (dga_db_display_done((Dga_window
)dgawin
, flag
, display_done_func
));
248 case DGA_DRAW_PIXMAP
:
250 /* not applicable to pixmaps - consider display done (to prevent hangs) */
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 */
265 return (dga_win_dbinfop((Dga_window
)dgawin
));
267 case DGA_DRAW_PIXMAP
:
269 /* not applicable to pixmaps - return NULL */