1 /* Copyright (c) 1993, 1998, 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 * dga_winshared.h - Sun Direct Graphics Access shared page include file.
28 #ifndef _DGA_WINSHARED_H
29 #define _DGA_WINSHARED_H
31 #include "dga_externaldefs.h"
32 #include <sys/int_types.h>
36 /* Mbufset Shared Info format */
37 typedef struct dga_mbufset_shinfo
{
38 unsigned int mbufseq
; /* incremented on composition or display
40 unsigned int compositionseq
; /* incremented on composition change */
41 unsigned char enabled
; /* nonzero if an mbufset is active */
42 unsigned char flipMode
; /* 0 = video flip; 1 = copy flip */
43 unsigned char accessMode
; /* 0 = single addr; 1 = multi addr */
44 unsigned char siteTypeConst
; /* zero if access mode can change */
45 uint32_t bufViewableFlags
; /* bit n is 1 if buf n is viewable */
46 unsigned int nmbufShpxToken
; /* token for shared pixmap file nonviewable
48 XID nmbufIds
[DGA_MAX_GRABBABLE_BUFS
]; /* XID's of nonviewable
50 #if !defined(_LP64) && !defined(_I32LPX)
51 int pad_bufIds
[DGA_MAX_GRABBABLE_BUFS
];
53 } DgaMbufSetShinfo
, *DgaMbufSetShinfoPtr
;
57 * This portion of the file file describes the shared memory info page
59 * grabber. Many of the structures are shapes specific, and their
60 * definitions are copied from shapes #include files. If the shapes
61 * structures are changed, then this file would be messed up; but
62 * if that happens, a lot of other things would get messed up too, so
63 * let's hope that it never happens.
65 * This structure is defined in such a way as to allow expansion. In
66 * particular, the field 'w_clipoff' contains the offset, in bytes, of
67 * the clip data relative to the start of the window information area.
68 * Do not attempt to refer directly to the 'w_shape_hdr' element of
69 * this structure, as that can cause old executables to break with new
72 * Here is a brief description of the WXINFO structure elements
73 * which are relavent to the client:
75 * w_flag set to WMODIF by the server whenever any field
76 * in the window info area is changed. Set back to
77 * WSEEN by the client once the info has been read.
78 * The window-info area should be locked while examining
79 * this flag and copying information from the
81 * w_magic Set to 0x47524142 ("GRAB").
82 * w_version version of window-info area. This header file
83 * currently describes version 1. Programs should
84 * check the version number and either refuse to run
85 * with older versions or at least be careful not to
86 * use fields not defined in older versions. The
87 * comments in the WXINFO structure definition will
88 * show you which these are.
89 * w_devname Ascii device name. Let's hope there's never a
90 * framebuffer with a filename larger than 20 characters.
91 * w_cinfofd File descriptor of wininfo file. This file has
92 * been mmap'ed, so there is no reason for the
93 * application to need to use this.
94 * w_cdevfd File descriptor of the framebuffer named in w_devname.
95 * w_crefcnt Lock count for nested locking.
96 * w_cookie Internal use only. NOT related to the window cookie
97 * that was returned by X_GrabWindow().
98 * w_clockp pointer to lockpage, used by wx_lock().
99 * w_clipoff Byte offset from start of info page to start of
101 * w_clipsize size of cliplist.
102 * w_org, w_dim window dimensions, i.e. bounding box of whole window
103 * In 16-bit signed fract format.
104 * w_shape cliplist info
105 * w_depth depth of window
106 * w_borderwidth server's idea of the window's bw. This need not be
107 * equal to what the client requested since
108 * something like OLWM could override the client
109 * request and the clinet now has wrong bw.
111 * Interpreting the clip info:
113 * The client is interested in the following structures:
114 * w_shape_hdr pointed to via the wx_clipinfo macro.
115 * w_shape contains flags and a bounding-box for the cliplist.
116 * cliparray follows w_shape. Contains the clip list.
118 * w_shape.SHAPE_FLAGS contains flags that describe the cliplist. If
119 * DGA_SH_EMPTY_FLAG is set, then the clip list is empty (window obscured or
122 * If DGA_SH_RECT_FLAG is set, the clip list is a single rectangle
123 * described by w_shape->SHAPE_{XMIN,YMIN,XMAX,YMAX}.
125 * For non-empty cliplists, use the dga_win_clipinfo(win) routine to get
126 * a pointer to the cliplist.
128 * "Normal" cliplists are a sequence of signed shorts which describes
129 * a sequence of rectangles. The data consists of a sequence of one
130 * or more ymin,ymax pairs, each of which is followed by a sequence of
131 * one or more xmin,xmax pairs. xmin,xmax sequences are terminated by
132 * a single value of DGA_X_EOL. ymin,ymax sequences are terminated by a
133 * single value of DGA_Y_EOL. This is best described with some sample
138 * ptr = dga_win_clipinfo(win);
139 * while( (y0=*ptr++) != DGA_Y_EOL )
142 * while( (x0=*ptr++) != DGA_X_EOL )
145 * printf("rectangle from (%d,%d) to (%d,%d)\n",x0,y0,x1-1,y1-1);
149 * Note that the xmax, ymax values are actually one pixel too high. This
150 * may be a bug or a feature, I don't know.
154 #define DGA_DB_DEV_INFO_SZ 132
156 #if !defined (WMODIF) /* cliplist flag, one of: */
157 #define WMODIF 1 /* server has set a new cliplist */
158 #define WEXTEND 2 /* extended cliplist present */
159 #define WXMAGIC 0x47524142 /* "GRAB" */
162 #define WX_PAGESZ (8*1024)
176 #if !defined (_SH_CLASS)
177 #if defined(_LP64) || defined(_I32LPX)
179 typedef OBJID CLASS_OPER
;
182 typedef OBJID (*CLASS_OPER
)();
193 unsigned int obj_flags
: 8;
194 unsigned int obj_size
: 24;
196 unsigned short obj_use
;
197 CLASS_OPER
*obj_func
;
198 #if !defined(_LP64) && !defined(_I32LPX)
202 #endif /* _SH_CLASS */
205 #if !defined (_SH_SHAPE_INT)
206 struct class_SHAPE_vn
{
207 unsigned char SHAPE_FLAGS
;
208 unsigned char SHAPE_SIZE
; /* new with 1.1 */
215 #if !defined(_LP64) && !defined(_I32LPX)
216 char pad_to_y_eol
[2];
221 OBJID obj
; /* new with 1.1 */
224 #if !defined(_LP64) && !defined(_I32LPX)
229 #define shape_obj u.obj
230 #define shape_xeol SHAPE_X_EOL
231 #define shape_yeol u.SHAPE_Y_EOL
232 #define SHAPE_RECT_SIZE (6 * sizeof (short))
233 #define SHAPE_NO_SIZE 0xFF
236 struct class_SHAPE_v0
{
237 unsigned char SHAPE_FLAGS
;
245 #endif /*_SH_SHAPE_INT*/
248 /* Cursor Grabber defines and structures */
250 #define DGA_CURSOR_DOWN 0
251 #define DGA_CURSOR_UP 1
252 #define DGA_CURG_MAGIC 0x43555247
255 typedef struct dga_curs_mpr
{
256 u_int curg_linebytes
;
257 Dga_coord_2d curg_dim
;
259 /* image data floats under here */
263 typedef struct dga_cursinfo
265 u_int c_magic
; /* magic no, "CURG"=0x43555247 */
266 u_int c_filesuffix
; /* to derive cursor grabber filename */
267 uint32_t c_pad
; /* No longer used */
268 int c_scurgfd
; /* file descriptor for server */
269 int c_ref_cnt
; /* total number of cur-grabbers*/
270 int c_state_flag
; /* client/server can set this */
271 u_int c_chng_cnt
; /* Change count */
272 int c_index
; /* entry no. in global array */
273 Dga_coord_2d c_org
; /* top left */
274 Dga_coord_2d c_hot_spot
; /* why bother with this? */
275 int c_offset
; /* offset in bytes from top of
276 * page to save_under info */
277 Dga_curs_mpr
*c_sptr
; /* server's ptr to save_unders*/
278 u_int c_cookie
; /* "cookie" for lock pages */
279 #if defined(_LP64) || defined(_I32LPX)
280 void* c_slockp
; /* all windows on this screen use */
281 void* c_sunlockp
; /* the same lock context */
283 void* c_slockp
; /* all windows on this screen use */
284 void* c_sunlockp
; /* the same lock context */
287 int c_smemsize
; /* number of bytes for saved cursor */
290 * FLOATING INFO STARTS HERE, CLIENT DO NOT
291 * REFER DIRECTLY TO ANYTHING BELOW THIS LINE.
294 Dga_curs_mpr c_saved_under
; /* this gets puts back up */
299 typedef struct wx_dbinfo
{
300 short number_buffers
;
303 short display_buffer
;
309 u_int WID
; /* Mpg window id. */
311 u_char device_info
[DGA_DB_DEV_INFO_SZ
];
314 /* Ancillary Buffers ... */
320 #ifndef DGA_NUM_BUFFER_TYPES
321 /* The following buffer types also defined(duplicated) in dga.h file.
322 * I can't include dga.h in hw/solaris/dga due to some declarations
323 * inconsistency. Whenever someone changes/addes/deleted
324 * to this enumerated values, please also update dga.h which is located
325 * in xc/include/dga/. Also ddx uses this.
328 DGA_DEPTH_BUFFER
= 0,
339 #define DGA_NUM_BUFFER_TYPES (DGA_AUX_BUFFER3+1)
342 /* dga_buffer: This structure will contain pDraw pointer and
343 * buffer_site as his first two members, since all the buffer
344 * API's type case the pointer to dga_buffer and dereference
345 * the buffer_site value.
346 * pDraw -> Will be assigned at the client side.
347 * buffer_site -> Software Buffers - DGA_SITE_SYSTEM
348 * Hardware Buffers - DGA_SITE_DEVICE
349 * fn -> shared of file name of the specified buffer.
350 * buffer_type -> Type of the buffer.
351 * sitechg -> Initialized to DGA_SITECHG_INITIAL when the
352 * buffer is created. When the buffer is getting
353 * reallocated, this will have DGA_SITECHG_CACHE.
354 * bitsPerPixel -> depth of the buffer
355 * bytesPerPixel-> (bitsPerPixel +7) >> 3
356 * width -> buffer width (Window's width)
357 * height -> buffer height (Window's height)
358 * linebytes -> ((bytesPerPixel * width) + 3) & ~3
359 * b_offset -> offset to data member from buffer address
360 * allocsize -> Shared file size.
361 * data -> Buffer data bits pointer.
362 * pad -> Padding to make sure it is 64-bit aligned, for now.
365 #if defined(_LP64) || defined(_I32LPX)
383 #if defined(_LP64) || defined(_I32LPX)
389 } dga_buffer_rec
, * dga_buffer
;
393 #if defined(_LP64) || defined(_I32LPX)
403 } dga_internal_buffer_rec
, *dga_internal_buffer
;
406 /* ABINFO: This structure contains buffer pointers and their
407 * respective filenames.
408 * s_modified -> Will be set to "1" when the buffer is resized.
409 * remap_flag -> This is used across server and client dga implementation
410 * buffer_swap -> swap counter.
413 typedef struct wx_abinfo
{
416 int width
; /* width & height are used to detect resize */
419 u_char depth_fn
[256];
420 u_char stencil_fn
[256];
421 u_char accum_fn
[256];
422 u_char alpha_fn
[256];
423 #if defined(_LP64) || defined(_I32LPX)
442 #if !defined(_LP64) && !defined(_I32LPX)
446 #if !defined(_LP64) && !defined(_I32LPX)
450 #if !defined(_LP64) && !defined(_I32LPX)
460 typedef struct wx_winfo
462 /* VERSION 0 INFO STARTS HERE */
464 uint32_t w_flag
; /* cliplist flag */
465 int32_t w_magic
; /* magic number, "GRAB" = 0x47524142 */
466 int32_t w_version
; /* version, currently 4 */
467 #if defined(_LP64) || defined(_I32LPX)
468 uint32_t w_cunlockp
; /* used to be w_list */
469 /* points to unlock page */
471 u_int
*w_cunlockp
; /* used to be w_list */
472 /* points to unlock page */
475 /* server info, meaningless to client */
477 int w_sinfofd
; /* fd of wxinfo file */
478 int w_sdevfd
; /* fd of framebuffer */
479 #if defined(_LP64) || defined(_I32LPX)
480 uint32_t w_slockp
; /* pointer to lockpage */
482 u_int
*w_slockp
; /* pointer to lockpage */
484 int w_srefcnt
; /* lock count for nested locks */
489 char w_devname
[20]; /* framebuffer device name */
490 int w_cinfofd
; /* fd of wxinfo file */
491 int w_cdevfd
; /* fd of framebuffer */
492 int w_crefcnt
; /* lock count for nested locks */
494 uint32_t w_cookie
; /* "cookie" for lock pages */
495 uint32_t w_filesuffix
; /* "cookie" for info file */
496 #if defined(_LP64) || defined(_I32LPX)
497 uint32_t w_clockp
; /* pointer to lock page */
499 u_int
*w_clockp
; /* pointer to lock page */
505 #if defined(_LP64) || defined(_I32LPX)
506 uint32_t w_cclipptr
; /* client virtual pointer to clip array. */
508 short *w_cclipptr
; /* client virtual pointer to clip array. */
510 u_int w_scliplen
; /* server's size of cliplist in bytes. */
515 POINT_B2D w_org
; /* origin of window */
516 POINT_B2D w_dim
; /* size of window */
519 /* VERSION 1 INFO STARTS HERE */
520 #if !defined(_LP64) && !defined(_I32LPX)
521 char pad_to_union
[4];
526 int32_t w_clipoff
; /* byte offset from wx_info to w_cliparray. */
527 int32_t w_shapeoff
; /* byte offset from wx_info to w_shape. */
528 u_int w_clipseq
; /* clip sequence number */
529 int32_t w_ccliplen
; /* client's size of clip list in bytes. */
530 #if defined(_LP64) || defined(_I32LPX)
531 uint32_t w_sclipptr
; /* server's pointer to clip array */
533 int *w_sclipptr
; /* server's pointer to clip array */
537 struct obj_hdr w_shape_hdr
; /* not useful to client */
538 struct class_SHAPE_v0 w_shape
;
543 /* VERSION 2 INFO STARTS HERE */
545 /* cursor grabber info */
547 u_int c_filesuffix
; /* to derive shared cursor filename */
548 #if defined(_LP64) || defined(_I32LPX)
549 uint32_t c_sinfo
; /* pointer to server's cursor info */
550 uint32_t c_pad1
; /* obsolete */
552 Dga_cursinfo
*c_sinfo
; /* pointer to server's cursor info */
553 void *c_pad1
; /* obsolete */
555 int c_pad2
; /* obsolete */
560 short number_wids
; /* number of contiguous wids alloc */
561 short start_wid
; /* starting wid */
562 short wid
; /* current wid */
563 short reserved_1
; /* for the future */
564 } w_wid_info
; /* WID info structure */
566 /* integer version of window bounds */
569 int xleft
, ytop
; /* upper-left corner, in pixels */
570 int width
, height
; /* dimensions, in pixels */
576 struct wx_dbinfo wx_dbuf
; /* double buffer info structure */
578 int w_auxdevfd
; /* Aux fd for asynch devices */
579 char w_auxdevname
[20]; /* Asynch device name */
580 short w_auxdevid
; /* ID number for aux dev type */
581 short w_auxserveronly
; /* To keep SERVER_ONLY's in sync */
582 #if defined(_LP64) || defined(_I32LPX)
583 uint32_t w_sunlockp
; /* pointer to unlockpage */
585 u_int
*w_sunlockp
; /* pointer to unlockpage */
587 int w_extnd_seq
; /* cliplist extension counter */
588 int w_clientcnt
; /* # of clients using new protocol */
589 int w_oldproto
; /* client used old protocol */
590 int w_locktype
; /* what type of locking */
592 #if defined(_LP64) || defined(_I32LPX)
593 uint32_t wdev
; /* pointer to server-internal data */
594 uint32_t w_srtndlink
; /* server's retained struct pointer */
596 void *wdev
; /* pointer to server-internal data */
597 char *w_srtndlink
; /* server's retained struct pointer */
599 u_int w_chng_cnt
; /* bumped when anything changes */
602 /* VERSION 3 INFO STARTS HERE */
604 u_char w_depth
; /* Window depth */
605 u_char pad
[1]; /* Padding for int alignment */
606 u_short w_borderwidth
; /* Actual bw of the window */
607 float w_refresh_period
; /* monitor refresh period- millisec */
608 #if !defined(_LP64) && !defined(_I32LPX)
613 * Attributes of multibuffer set
615 * Note: the number of buffers in an mbuf set is specified by
616 * wx_dbuf.number_buffers.
619 DgaMbufSetShinfo w_mbsInfo
; /*info for multibuf set (if win is mbuf) */
620 #if !defined(_LP64) && !defined(_I32LPX)
623 u_int w_devinfoseq
; /*devinfo seq. # in the Dga_dbinfo struct.*/
624 int w_obsolete
; /* 0 when shinfo no longer is valid */
625 int w_visibility
; /* visibility of window. */
627 /* VERSION 4 INFO STARTS HERE */
629 Bool w_ovlshapevalid
; /* client will clear this when locking */
630 /* so the server knows to recalculate */
631 /* the overlay's opaque shape */
632 int w_ovlstate
; /* conflict mode of an overlay, one of: */
633 /* MPG_NONE => DGA_OVLSTATE_SAFE */
634 /* MPG_SAFE => DGA_OVLSTATE_SAFE */
635 /* MPG_SOFT => DGA_OVLSTATE_MULTIWID */
636 /* MPG_HARD => DGA_OVLSTATE_CONFLICT */
638 /* VERSION 5 INFO STARTS HERE */
639 #if !defined(_LP64) && !defined(_I32LPX)
640 char pad_ovlstate
[4];
643 struct wx_abinfo wx_abuf
; /* Ancillay Buffers info structure */
644 #if !defined(_LP64) && !defined(_I32LPX)
650 * FLOATING INFO STARTS HERE, DO NOT REFER
651 * DIRECTLY TO ANYTHING BELOW THIS LINE.
654 #if !defined(_LP64) && !defined(_I32LPX)
659 struct class_SHAPE_vn w_shape
;
664 #define WG_LOCKDEV 0 /* use GRABPAGEALLOC from fb */
665 #define WG_WINLOCK 1 /* use winlock functions */
667 #endif /* _DGA_WINSHARED_H */