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.
24 #ifndef _DGA_INTERNAL_H
25 #define _DGA_INTERNAL_H
28 * dga_internal.h - Sun Direct Graphics Access interface internal include file
31 /* Note that _Dga_window, _Dga_cmap, _Dga_pixmap are all internal declarations
32 * for the externally visible Dga_window, Dga_cmap and Dga_pixmap ( no leading
33 * underscore). In the externally visible include file, these are all declared
34 * as void * and thus quite opaque.
36 * Note: there is a DGA_FAST_DRAW_LOCK() macro that also access the
37 * fields in struct dga_window and dga_pixmap but is not currently in dga.h.
38 * Consider this macro before modifying fields.
41 typedef u_int
*Dga_lockp
;
43 typedef struct dga_mbufset
*DgaMbufSetPtr
;
46 /* used only to get at the drawable type. After that, we vector off
47 to either a window or pixmap routine */
48 typedef struct dga_drawable
{
49 int drawable_type
; /* pointer to drawable type */
52 typedef struct dga_window
{
53 int drawable_type
; /* pointer to drawable type */
54 u_int c_chngcnt
; /* last recorded window change count */
55 u_int
*s_chngcnt_p
; /* ptr to server's global change cnt */
56 int w_lockcnt
; /* lock count for nested locks */
57 Dga_lockp w_lockp
; /* pointer to lock page */
58 Dga_lockp w_unlockp
; /* points to unlock page */
60 mutex_t
*mutexp
; /* points to drawable's mutex */
62 int (*w_lock_func
)(); /* alternate function for locking */
64 int (*w_unlock_func
)(Dga_drawable
); /* alternate func for unlocking */
65 int (*w_update_func
)(Dga_drawable
);
66 int w_modif
; /* cached result of update check */
67 u_int c_wm_chngcnt
[17]; /* last recorded global change counts */
68 u_int
*w_wm_2nd
; /* Ptr to second entry in wm_chngcnt[]*/
69 void *w_info
; /* pointer to shared memory */
70 u_int c_clipseq
; /* last recorded clip change count */
71 u_int
*s_clipseq_p
; /* ptr to server's clip change count */
72 short *w_clipptr
; /* client virtual ptr to clip array. */
73 u_int w_cliplen
; /* client's size of cliplist in bytes*/
74 Dga_token w_token
; /* token used to grab window */
75 int w_infofd
; /* fd of shared memory file */
76 int w_devfd
; /* fd of framebuffer */
77 int w_grab_count
; /* how many times we've grabbed it */
78 struct dga_window
*w_next
; /* used to link all grabbed windows */
79 void *w_lib_private
; /* library private data */
80 void *w_client
; /* for client use */
83 /* cursor grabber info */
84 void *curs_info
; /* pointer to client's cursor info */
85 int curs_fd
; /* Client side file descriptor */
86 u_int c_curseq
; /* last recorded cursor change count */
87 u_int
*s_curseq_p
; /* ptr to server's cursor change cnt */
89 /* Ancillay Buffer info */
98 /* double buffering info */
99 u_int db_enabled
; /* flag to tell if initialized */
100 u_int
*db_vrtcntrp
; /* Client's ptr to VRT counter */
101 u_int db_lastvrtcntr
; /* VRT counter value at last flip */
102 u_int db_swapint
; /* number of intervals between flips */
103 int (*vrt_func
)(Dga_window
);/* user supplied vrt retrace func */
105 /* retained window grabber info */
106 int rtn_fd
; /* Client side fd for shared memory */
107 u_int rtn_size
; /* Client size of pixel block in bytes */
108 u_int c_rtnseq
; /* Client rtn modification counter */
109 u_int
*s_rtnseq_p
;/* Ptr to server's rtn mod counter */
110 u_int c_rtncachseq
;/* Client device cache modification counter */
111 u_int
*s_rtncachseq_p
; /* Ptr to server's dev cache modification counter */
112 void *rtn_info
; /* Ptr to Shared memory structure */
113 void *rtn_pixels
; /* Client ptr to Client pixel mapping */
114 u_int rtn_flags
; /* to record state of retained grab */
117 ** New fields for drawable grabber.
120 Display
*w_dpy
; /* display the window belongs to */
121 Window w_id
; /* XID of window */
122 DgaMbufSetPtr pMbs
; /* Non-null for multibuf wins */
123 u_int
*s_mbufseq_p
; /* pointer to mbuf seq in shinfo */
124 u_int c_mbufseq
; /* last mbufset composition sequence count */
125 u_int
*s_mbcomposseq_p
; /* pointer to mbufset compos seq in shinfo */
126 u_int c_mbcomposseq
; /* last mb state sequence count */
127 u_int
*s_devinfoseq_p
; /* pointer to devinfo seq in shinfo */
128 u_int c_devinfoseq
; /* last devinfo state sequence count */
130 /* notification functions */
131 DgaSiteNotifyFunc siteNotifyFunc
;
132 void *siteNotifyClientData
;
133 DgaMbNotifyFunc mbNotifyFunc
;
134 void *mbNotifyClientData
;
135 DgaRendBufNotifyFunc rendBufNotifyFunc
;
136 void *rendBufNotifyClientData
;
138 /* real lock subject - the win/mbuf currently locked by the client */
141 /* effective lock subject - the actual lock subject. This will be used by
142 the DGA state inquiry functions called by the client. If the
143 win/mbuf is not aliased, eLockSubj will be the same as rLockSubj */
146 /* previous effective lock subject - the lock subject for which a
147 change was last signalled to the client. It is assumed that the
148 client synchronized its state to this lock subject. This is always
149 true for well-behaved DGA clients */
152 /* mbChgReason is the reason for an mbufset change. prevWasMbuffered
153 is used to help us figure this out. It is set during the update
154 phase and may be used during the inquiry phase */
155 char prevWasMbuffered
;
158 /* used during update phase to indicate what state changed */
161 /* reason for any site change */
164 /* Has the window been previously locked? */
171 * If the window is an overlay, the isOverlay flag will be set to
172 * true and the s_ovlstate_p pointer will point to the ovlstate
173 * flag on the shared page and the s_ovlshapevalid_p pointer will
174 * point to the w_ovl_shape_valid flag.
179 int *s_ovlshapevalid_p
;
180 DgaOvlStateNotifyFunc ovlStateNotifyFunc
;
181 void *ovlStateNotifyClientData
;
184 /* For the threaded case, this stores the real change counts while
185 * c_wm_chngcnt[] is used to force the update function to be called.
187 u_int shadow_chngcnt
[17];
193 typedef struct _dgaLastSeqs
{
198 } DgaLastSeqs
, *DgaLastSeqsPtr
;
200 typedef struct dga_cmap
{
201 void *cm_info
;/* pointer to shared memory */
202 u_int c_chngcnt
; /* last recorded change count */
203 u_int
*s_chngcnt_p
; /* last recorded change count */
204 int cm_lockcnt
; /* lock count for nested locks */
205 u_int
*cm_lockp
; /* pointer to lock page */
206 u_int
*cm_unlockp
; /* pointer to unlock page */
207 int cm_use_new_ioctl
; /* use new hardware ioctl? */
208 Dga_token cm_token
; /* token used to grab cmap */
209 int cm_infofd
; /* fd of shared memory file */
210 int cm_devfd
; /* fd of framebuffer */
211 int cm_lockfd
; /* fd of lock device
212 * (if not framebuffer) */
213 int cm_sunwindows_def_fd
; /* client fd for server's
214 SunWindows default cmap window */
215 int cm_sunwindows_inst_fd
; /* client fd for server's
216 SunWindows installed cmap window */
217 int cm_grab_count
; /* how many times we've grabbed it */
218 struct dga_cmap
*cm_next
; /* used to link all grabbed cmaps */
219 void *cm_lib_private
; /* library private data */
220 void *cm_client
; /* for client use */
224 * When the pixmap interface is made public, this declaration should be
225 * moved into the dga.h file and taken out of the dga_internal.h file
226 * Also the lock routiens currently in pix_grab,c should be made into
227 * macros and added to dga.h
230 typedef struct dga_pixmap
{
231 int drawable_type
; /* pointer to drawable type - window/pixmap*/
232 u_int obsolete
; /* last recorded global change count */
233 u_int
*s_chngcnt_p
; /* ptr to server's global change cnt */
234 int p_lockcnt
; /* lock count for nested locks */
235 Dga_lockp p_lockp
; /* pointer to lock page */
236 Dga_lockp p_unlockp
; /* points to unlock page */
238 mutex_t
*mutexp
; /* points to drawable's mutex */
240 int (*p_lock_func
)(); /* alternate function for locking */
242 int (*p_unlock_func
)(Dga_drawable
); /* alternate func for unlocking */
243 int (*p_update_func
)(Dga_drawable
, short); /* function to call for updates */
244 int p_modif
; /* cached result of update check ?? */
245 u_int c_chngcnt
[1]; /* Last recorded global change count */
246 u_int
*p_chngcnt_2nd
; /* Pts to c_chngcnt[0]*/
247 void *p_infop
; /* pointer to shared pixmap memory*/
248 /* TODO: Why are the next two entries in here? It's not clear to me why
249 * the client side cares if the shpx_dir changes. The only time a pixmap
250 * is removed from the directory structure is when it is destroyed and
251 * then the obsolete flag is set. */
252 u_int c_dirchngcnt
; /* Client's last recorderd dir chng cnt */
253 u_int
*s_dirchngcnt_p
;/* Ptr to server's dir chng cnt */
254 u_int c_devinfocnt
; /* Client's last recorded devinfo seq cnt */
255 u_int
*s_devinfocnt_p
; /* Ptr to server's devinfo seq cnt */
256 u_int c_cachecnt
; /* Client's last recorded cache sequence cnt */
257 u_int
*s_cachecnt_p
; /* ptr to Server cache sequence count */
258 u_char c_cached
; /* Client's last recorded cache state */
259 u_char
*s_cached_p
; /* Ptr to server's cache state */
260 u_int p_dir_index
; /* Client's pixmap's directory index */
261 void *p_shpx_dir
; /* Client's ptr to the shpx dir */
262 void *p_shpx_client
; /* Client's ptr to the shpx client struct */
263 Dga_token p_token
; /* token used to grab window */
264 u_int c_size
; /* Client's size of pixel array */
265 u_char
*c_pixels
; /* pointer to clients pixels */
266 u_char depth
; /* pixmap depth in bits */
267 char pad0
; /* padding to align to int */
268 u_short pad1
; /* padding to align to int */
269 u_int linebytes
; /* pixmap linebyte */
270 struct dga_pixmap
*p_next
; /* used to link all grabbed pixmaps */
271 int p_infofd
; /* fd of shared memory file */
272 u_int pix_flags
; /* to record state of grab ?? */
274 Pixmap p_id
; /* XID of pixmap */
275 void *p_client
; /* for client use */
277 /* used during update phase to indicate what state changed */
280 /* reason for any site change */
284 DgaSiteNotifyFunc siteNotifyFunc
;
285 void *siteNotifyClientData
;
287 /* For the threaded case, this stores the real change counts while
288 * c_chngcnt[] is used to force the update function to be called.
290 u_int shadow_chngcnt
[1];
294 typedef void * Dga_pixmap
;
297 extern mutex_t dgaGlobalMutex
;
298 extern mutex_t dgaGlobalPixmapMutex
;
299 extern int dgaThreaded
;
304 extern int dgai_unlock(Dga_drawable dgadraw
);
307 /* Pixmap grabber routines - these are not Public yet */
308 extern Dga_token
XDgaGrabPixmap(Display
*, Pixmap
);
309 extern int XDgaUnGrabPixmap(Display
*, Pixmap
);
310 extern Dga_pixmap
dga_pix_grab(Dga_token
, Pixmap
);
311 extern void dga_pix_ungrab(Dga_pixmap
);
312 extern int dga_pix_cachechg(Dga_pixmap
);
313 extern int dga_pix_cached(Dga_pixmap
);
314 extern char* dga_pix_devname(Dga_pixmap
);
315 extern void *dga_pix_pixels(Dga_pixmap
);
316 extern int dga_pix_linebytes(Dga_pixmap
);
317 extern u_char
dga_pix_depth(Dga_pixmap
);
318 extern void *dga_pix_devinfo(Dga_pixmap
);
321 /* These are always going to be private routines to be backward
324 extern int XDgaGrabRetainedWindow(Display
*, Window
);
325 extern int XDgaUnGrabRetainedWindow(Display
*, Window
);
326 extern int XDgaGetRetainedPath(Display
*, Window
, char*);
327 extern int XDgaQueryVersion(Display
*, int*, int*);
328 extern int XDgaGrabBuffers(Display
*, Window
, int );
329 extern int XDgaUnGrabBuffers(Display
*, Window
);
330 extern void dga_cm_get(Dga_cmap
, int, int, u_char
*, u_char
*,
332 extern void dga_cm_put(Dga_cmap
, int, int, u_char
*, u_char
*,
334 extern int dga_db_access(Dga_window
);
335 extern void dga_db_release(Dga_window
);
336 extern int dga_db_display_complete(Dga_window
, int);
337 extern void *dga_rtn_devinfo(Dga_window
);
340 ** Internal mbuf grab routine
343 extern Dga_window
dga_mbuf_grab (int devfd
, Dga_token winToken
);
346 ** Internal mbufset member update routines
349 extern int dgai_mbsmemb_update (Dga_drawable dgadraw
, short bufIndex
);
350 extern int dgai_mbsmemb_syncZombie (_Dga_window dgawin
);
351 extern void dgai_mbsmemb_syncMbufset (_Dga_window dgawin
);
352 extern void dgai_mbsmemb_syncRendBuf (_Dga_window dgawin
);
353 extern void dgai_mbsmemb_figureDerivChgs (_Dga_window dgawin
);
354 extern void dgai_mbsmemb_notify (_Dga_window dgawin
);
355 extern void dgai_mbsmemb_devinfo_update(_Dga_window dgawin
);
359 ** Internal window update routines
362 extern Dga_window
dgai_win_grab_common (Display
*dpy
, int devfd
, Dga_token token
, int drawableGrabber
);
363 extern int dgai_win_update (_Dga_window dgawin
, short bufIndex
);
364 extern void dgai_win_clip_update(_Dga_window dgawin
);
365 extern void dgai_win_curs_update(_Dga_window dgawin
);
366 extern void dgai_win_rtn_update(_Dga_window dgawin
);
367 extern void dgai_win_syncChanges (_Dga_window dgawin
, DgaLastSeqsPtr pLastSeqs
);
368 extern int dgai_win_visibility(Dga_window wini
);
371 ** Internal multibuffer update routines
374 extern int dgai_mbuf_update (_Dga_window dgawin
, short bufIndex
);
375 extern void dgai_vmbuf_syncChanges (_Dga_window dgawin
, DgaLastSeqsPtr pLastSeqs
, short bufIndex
);
376 extern void dgai_nmbuf_syncChanges (_Dga_window dgawin
);
377 extern void dgai_nmbuf_cache_update(_Dga_window dgawin
);
378 extern void dgai_nmbuf_devinfo_update(_Dga_window dgawin
);
381 ** Internal multibuffer set routines
384 extern DgaMbufSetPtr
dgai_mbufset_create (_Dga_window dgawin
);
385 extern void dgai_mbufset_incref (DgaMbufSetPtr pMbs
);
386 extern void dgai_mbufset_decref (DgaMbufSetPtr pMbs
);
389 ** Internal mbufset member inquiry routines
392 extern Display
* dgai_mbsmemb_display (_Dga_window dgawin
);
393 extern char * dgai_mbsmemb_devname (_Dga_window dgawin
);
394 extern int dgai_mbsmemb_devfd (_Dga_window dgawin
);
395 extern int dgai_mbsmemb_depth (_Dga_window dgawin
);
396 extern void dgai_mbsmemb_set_client_infop (_Dga_window dgawin
, void *client_info_ptr
);
397 extern void * dgai_mbsmemb_get_client_infop (_Dga_window dgawin
);
398 extern void * dgai_mbsmemb_devinfo (_Dga_window dgawin
);
399 extern int dgai_mbsmemb_sitechg (_Dga_window dgawin
, int *reason
);
400 extern void dgai_mbsmemb_sitesetnotify (_Dga_window dgawin
,
401 DgaSiteNotifyFunc site_notify_func
,
403 extern void dgai_mbsmemb_sitegetnotify (_Dga_window dgawin
,
404 DgaSiteNotifyFunc
*site_notify_func
,
406 extern int dgai_mbsmemb_site (_Dga_window dgawin
);
407 extern void * dgai_mbsmemb_address (_Dga_window dgawin
);
408 extern int dgai_mbsmemb_linebytes (_Dga_window dgawin
);
409 extern int dgai_mbsmemb_bitsperpixel (_Dga_window dgawin
);
410 extern int dgai_mbsmemb_clipchg (_Dga_window dgawin
);
411 extern void dgai_mbsmemb_bbox(_Dga_window dgawin
, int *xp
, int *yp
,
412 int *widthp
, int *heightp
);
413 extern int dgai_mbsmemb_visibility (_Dga_window dgawin
);
414 extern int dgai_mbsmemb_empty (_Dga_window dgawin
);
415 extern short * dgai_mbsmemb_clipinfo (_Dga_window dgawin
);
416 extern int dgai_mbsmemb_singlerect (_Dga_window dgawin
);
417 extern int dgai_mbsmemb_obscured (_Dga_window dgawin
);
418 extern u_short
dgai_mbsmemb_borderwidth (_Dga_window dgawin
);
419 extern void dgai_mbsmemb_curshandle (_Dga_window dgawin
, DgaCursTakeDownFunc take_down_func
,
421 extern int dgai_mbsmemb_rtngrab (_Dga_window dgawin
);
422 extern int dgai_mbsmemb_rtnungrab (_Dga_window dgawin
);
423 extern int dgai_mbsmemb_rtnchg (_Dga_window dgawin
);
424 extern int dgai_mbsmemb_rtnactive (_Dga_window dgawin
);
425 extern int dgai_mbsmemb_rtncached (_Dga_window dgawin
);
426 extern void * dgai_mbsmemb_rtndevinfop (_Dga_window dgawin
);
427 extern void dgai_mbsmemb_rtndevtype (_Dga_window dgawin
, u_char
*type
,
429 extern void dgai_mbsmemb_rtndimensions (_Dga_window dgawin
, short *width
,
430 short *height
, u_int
*linebytes
);
431 extern int dgai_mbsmemb_rtnbitsperpixel(_Dga_window dgawin
);
432 extern void * dgai_mbsmemb_rtnpixels (_Dga_window dgawin
);
433 extern int dgai_mbsmemb_mbchg (_Dga_window dgawin
, int *reason
);
434 extern void dgai_mbsmemb_mbsetnotify (_Dga_window dgawin
, DgaMbNotifyFunc mb_notify_func
,
436 extern void dgai_mbsmemb_mbgetnotify (_Dga_window dgawin
, DgaMbNotifyFunc
*mb_notify_func
,
438 extern int dgai_mbsmemb_mbaccessmode (_Dga_window dgawin
);
439 extern int dgai_mbsmemb_mbsitetypeconst (_Dga_window dgawin
);
440 extern void dgai_mbsmemb_mbsetrendbufnotify (_Dga_window dgawin
,
441 DgaRendBufNotifyFunc rb_notify_func
,
443 extern void dgai_mbsmemb_mbgetrendbufnotify (_Dga_window dgawin
,
444 DgaRendBufNotifyFunc
*rb_notify_func
,
446 extern int dgai_mbsmemb_ovlstatechg (_Dga_window dgawin
);
447 extern int dgai_mbsmemb_ovlstate (_Dga_window dgawin
);
448 extern void dgai_mbsmemb_setovlstatenotify (_Dga_window dgawin
,
449 DgaOvlStateNotifyFunc ovlstate_notify_func
,
451 extern void dgai_mbsmemb_getovlstatenotify (_Dga_window dgawin
,
452 DgaOvlStateNotifyFunc
*ovlstate_notify_func
,
457 ** Internal pixmap inquiry routines
460 /* TODO: dhuff: must supply */
462 extern int dgai_pix_update(Dga_drawable dgadraw
, short bufIndex
);
463 extern Display
* dgai_pix_display (_Dga_pixmap dgapix
);
464 extern char * dgai_pix_devname (_Dga_pixmap dgapix
);
465 extern int dgai_pix_devfd (_Dga_pixmap dgapix
);
466 extern int dgai_pix_depth (_Dga_pixmap dgapix
);
467 extern void dgai_pix_set_client_infop (_Dga_pixmap dgapix
, void *client_info_ptr
);
468 extern void * dgai_pix_get_client_infop (_Dga_pixmap dgapix
);
469 extern void * dgai_pix_devinfo (_Dga_pixmap dgapix
);
470 extern int dgai_pix_sitechg (_Dga_pixmap dgapix
, int *reason
);
471 extern void dgai_pix_sitesetnotify (_Dga_pixmap dgapix
,
472 DgaSiteNotifyFunc site_notify_func
,
474 extern void dgai_pix_sitegetnotify (_Dga_pixmap dgapix
,
475 DgaSiteNotifyFunc
*site_notify_func
,
477 extern int dgai_pix_site (_Dga_pixmap dgapix
);
478 extern void * dgai_pix_address (_Dga_pixmap dgapix
);
479 extern int dgai_pix_linebytes (_Dga_pixmap dgapix
);
480 extern int dgai_pix_bitsperpixel (_Dga_pixmap dgapix
);
481 extern int dgai_pix_clipchg (_Dga_pixmap dgapix
);
482 extern void dgai_pix_bbox(_Dga_pixmap dgapix
, int *xp
, int *yp
,
483 int *widthp
, int *heightp
);
484 extern int dgai_pix_empty (_Dga_pixmap dgapix
);
485 extern short * dgai_pix_clipinfo (_Dga_pixmap dgapix
);
487 #endif /* _DGA_INTERNAL_H */