2 * $XConsortium: multibufst.h,v 1.16 95/06/08 23:20:39 gildea Exp $
3 * $XFree86: xc/include/extensions/multibufst.h,v 3.1 1996/05/06 05:52:39 dawes Exp $
5 Copyright (c) 1989 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
29 #ifndef _MULTIBUFST_H_
30 #define _MULTIBUFST_H_
33 * Protocol requests constants and alignment values
37 #ifdef _MULTIBUF_SERVER_
41 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
42 #define MbufGetReq(name,req,info) GetReq (name, req); \
43 req->reqType = info->codes->major_opcode; \
44 req->mbufReqType = X_##name;
46 #define MbufGetReq(name,req,info) GetReq (name, req); \
47 req->reqType = info->codes->major_opcode; \
48 req->mbufReqType = X_/**/name;
52 #define Drawable CARD32
53 #define VisualID CARD32
54 #define Multibuffer CARD32
56 typedef struct xMbufBufferInfo {
57 CARD32 visualID B32; /* associated visual */
58 CARD16 maxBuffers B16; /* maximum supported buffers */
59 CARD8 depth; /* depth of visual (redundant) */
62 #define sz_xMbufBufferInfo 8
67 CARD16 sequenceNumber B16;
68 CARD32 buffer B32; /* affected buffer */
69 BYTE state; /* current status */
77 } xMbufClobberNotifyEvent;
82 CARD16 sequenceNumber B16;
83 CARD32 buffer B32; /* affected buffer */
84 CARD32 timeStamp B32; /* update time */
91 } xMbufUpdateNotifyEvent;
94 CARD8 reqType; /* always codes->major_opcode */
95 CARD8 mbufReqType; /* always X_MbufGetBufferVersion */
97 } xMbufGetBufferVersionReq;
98 #define sz_xMbufGetBufferVersionReq 4
101 BYTE type; /* X_Reply */
102 CARD8 unused; /* not used */
103 CARD16 sequenceNumber B16;
105 CARD8 majorVersion; /* major version of Multi-Buffering protocol */
106 CARD8 minorVersion; /* minor version of Multi-Buffering protocol */
113 } xMbufGetBufferVersionReply;
114 #define sz_xMbufGetBufferVersionReply 32
117 CARD8 reqType; /* always codes->major_opcode */
118 CARD8 mbufReqType; /* always X_MbufCreateImageBuffers */
120 CARD32 window B32; /* associated window */
121 CARD8 updateAction; /* action at update */
122 CARD8 updateHint; /* hint as to frequency of updates */
124 } xMbufCreateImageBuffersReq; /* followed by buffer ids */
125 #define sz_xMbufCreateImageBuffersReq 12
128 BYTE type; /* X_Reply */
129 CARD8 unused; /* not used */
130 CARD16 sequenceNumber B16;
132 CARD16 numberBuffer B16; /* number successfully allocated */
139 } xMbufCreateImageBuffersReply;
140 #define sz_xMbufCreateImageBuffersReply 32
143 CARD8 reqType; /* always codes->major_opcode */
144 CARD8 mbufReqType; /* always X_MbufDestroyImageBuffers */
146 CARD32 window B32; /* associated window */
147 } xMbufDestroyImageBuffersReq;
148 #define sz_xMbufDestroyImageBuffersReq 8
151 CARD8 reqType; /* always codes->major_opcode */
152 CARD8 mbufReqType; /* always X_MbufDisplayImageBuffers */
154 CARD16 minDelay B16; /* minimum time between last update and now */
155 CARD16 maxDelay B16; /* maximum time between last update and now */
156 } xMbufDisplayImageBuffersReq; /* followed by list of buffers */
157 #define sz_xMbufDisplayImageBuffersReq 8
160 CARD8 reqType; /* always codes->major_opcode */
161 CARD8 mbufReqType; /* always X_MbufSetMBufferAttributes */
163 CARD32 window B32; /* associated window */
164 CARD32 valueMask B32; /* modified entries */
165 } xMbufSetMBufferAttributesReq; /* followed by values */
166 #define sz_xMbufSetMBufferAttributesReq 12
169 CARD8 reqType; /* always codes->major_opcode */
170 CARD8 mbufReqType; /* always X_MbufGetMBufferAttributes */
172 CARD32 window B32; /* associated window */
173 } xMbufGetMBufferAttributesReq;
174 #define sz_xMbufGetMBufferAttributesReq 8
177 BYTE type; /* X_Reply */
178 CARD8 unused; /* not used */
179 CARD16 sequenceNumber B16;
181 CARD16 displayedBuffer B16; /* currently visible buffer */
191 } xMbufGetMBufferAttributesReply;
192 #define sz_xMbufGetMBufferAttributesReply 32
195 CARD8 reqType; /* always codes->major_opcode */
196 CARD8 mbufReqType; /* always X_MbufSetBufferAttributes */
199 CARD32 valueMask B32;
200 } xMbufSetBufferAttributesReq; /* followed by values */
201 #define sz_xMbufSetBufferAttributesReq 12
204 CARD8 reqType; /* always codes->major_opcode */
205 CARD8 mbufReqType; /* always X_MbufGetBufferAttributes */
208 } xMbufGetBufferAttributesReq;
209 #define sz_xMbufGetBufferAttributesReq 8
212 BYTE type; /* X_Reply */
213 CARD8 unused; /* not used */
214 CARD16 sequenceNumber B16;
217 CARD32 eventMask B32;
218 CARD16 bufferIndex B16;
224 } xMbufGetBufferAttributesReply;
225 #define sz_xMbufGetBufferAttributesReply 32
228 CARD8 reqType; /* always codes->major_opcode */
229 CARD8 mbufReqType; /* always X_MbufGetBufferInfo */
231 Drawable drawable B32;
232 } xMbufGetBufferInfoReq;
233 #define sz_xMbufGetBufferInfoReq 8
236 BYTE type; /* X_Reply */
237 CARD8 unused; /* not used */
238 CARD16 sequenceNumber B16;
240 CARD16 normalInfo B16;
241 CARD16 stereoInfo B16;
247 } xMbufGetBufferInfoReply; /* followed by buffer infos */
248 #define sz_xMbufGetBufferInfoReply 32
252 CARD8 reqType; /* always codes->major_opcode */
253 CARD8 mbufReqType; /* always X_MbufCreateStereoWindow */
261 Multibuffer left B32; /* associated buffers */
262 Multibuffer right B32;
267 CARD16 borderWidth B16;
271 } xMbufCreateStereoWindowReq; /* followed by value list */
272 #define sz_xMbufCreateStereoWindowReq 44
275 CARD8 reqType; /* always codes->major_opcode */
276 CARD8 mbufReqType; /* always X_MbufClearImageBufferArea */
278 Multibuffer buffer B32;
287 } xMbufClearImageBufferAreaReq;
288 #define sz_xMbufClearImageBufferAreaReq 20
296 #ifdef _MULTIBUF_SERVER_
297 /* Macros for wrapping and unwrapping functions */
299 #define SWAP_FUNC_VECTOR(pSTRUCT1,pSTRUCT2,DATA_TYPE,FUNC_NAME) \
301 DATA_TYPE (* tmpFn)(); \
303 tmpFn = pSTRUCT1->FUNC_NAME; \
304 pSTRUCT1->FUNC_NAME = pSTRUCT2->FUNC_NAME; \
305 pSTRUCT2->FUNC_NAME = tmpFn; \
308 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
309 #define WRAP_SCREEN_FUNC(pSCREEN,pPRIV,FUNC_NAME, PRIV_FUNC_NAME) \
311 if ((pPRIV->funcsWrapped & FUNC_NAME##Mask) == 0) \
313 pPRIV->FUNC_NAME = pSCREEN->FUNC_NAME; \
314 pSCREEN->FUNC_NAME = PRIV_FUNC_NAME; \
315 pPRIV->funcsWrapped |= FUNC_NAME##Mask; \
319 #define UNWRAP_SCREEN_FUNC(pSCREEN,pPRIV,DATA_TYPE,FUNC_NAME) \
321 SWAP_FUNC_VECTOR(pSCREEN,pPRIV,DATA_TYPE,FUNC_NAME); \
322 pPRIV->funcsWrapped &= ~(FUNC_NAME##Mask); \
325 #define REWRAP_SCREEN_FUNC(pSCREEN,pPRIV,DATA_TYPE,FUNC_NAME) \
327 if (MB_SCREEN_PRIV(pSCREEN)->mbufWindowCount) \
329 SWAP_FUNC_VECTOR(pSCREEN,pPRIV,DATA_TYPE,FUNC_NAME); \
330 pPRIV->funcsWrapped |= FUNC_NAME##Mask; \
334 #define WRAP_SCREEN_FUNC(pSCREEN,pPRIV,FUNC_NAME, PRIV_FUNC_NAME) \
336 if ((pPRIV->funcsWrapped & FUNC_NAME/**/Mask) == 0) \
338 pPRIV->FUNC_NAME = pSCREEN->FUNC_NAME; \
339 pSCREEN->FUNC_NAME = PRIV_FUNC_NAME; \
340 pPRIV->funcsWrapped |= FUNC_NAME/**/Mask; \
344 #define UNWRAP_SCREEN_FUNC(pSCREEN,pPRIV,DATA_TYPE,FUNC_NAME) \
346 SWAP_FUNC_VECTOR(pSCREEN,pPRIV,DATA_TYPE,FUNC_NAME); \
347 pPRIV->funcsWrapped &= ~(FUNC_NAME/**/Mask); \
350 #define REWRAP_SCREEN_FUNC(pSCREEN,pPRIV,DATA_TYPE,FUNC_NAME) \
352 if (MB_SCREEN_PRIV(pSCREEN)->mbufWindowCount) \
354 SWAP_FUNC_VECTOR(pSCREEN,pPRIV,DATA_TYPE,FUNC_NAME); \
355 pPRIV->funcsWrapped |= FUNC_NAME/**/Mask; \
360 /* The _Multibuffer and _Multibuffers structures below refer to each other,
361 * so we need this forward declaration
363 typedef struct _Multibuffers *MultibuffersPtr;
366 * per-Multibuffer data
369 typedef struct _Multibuffer {
370 MultibuffersPtr pMultibuffers; /* associated window data */
371 Mask eventMask; /* MultibufferClobberNotifyMask|ExposureMask|MultibufferUpdateNotifyMask */
372 Mask otherEventMask; /* mask of all other clients event masks */
373 OtherClients *otherClients; /* other clients that want events */
374 int number; /* index of this buffer into array */
375 int side; /* always Mono */
376 int clobber; /* Unclobbered, PartiallyClobbered, FullClobbered */
377 PixmapPtr pPixmap; /* associated pixmap */
378 } MultibufferRec, *MultibufferPtr;
384 typedef struct _Multibuffers {
385 WindowPtr pWindow; /* associated window */
386 int numMultibuffer; /* count of buffers */
387 int refcnt; /* ref count for delete */
388 int displayedMultibuffer; /* currently active buffer */
389 int updateAction; /* Undefined, Background, Untouched, Copied */
390 int updateHint; /* Frequent, Intermittent, Static */
391 int windowMode; /* always Mono */
393 TimeStamp lastUpdate; /* time of last update */
395 unsigned short width, height; /* last known window size */
396 short x, y; /* for static gravity */
398 MultibufferPtr buffers; /* array of numMultibuffer buffers */
404 typedef struct _MultibufferScreen {
405 PositionWindowProcPtr PositionWindow; /* pWin, x,y */
406 } MultibufferScreenRec, *MultibufferScreenPtr;
409 * per display-image-buffers request data.
412 typedef struct _DisplayRequest {
413 struct _DisplayRequest *next;
414 TimeStamp activateTime;
417 } DisplayRequestRec, *DisplayRequestPtr;
419 #define DestroyWindowMask (1L<<0)
420 #define PositionWindowMask (1L<<1)
421 #define PostValidateTreeMask (1L<<2)
422 #define ClipNotifyMask (1L<<3)
423 #define WindowExposuresMask (1L<<4)
424 #define CopyWindowMask (1L<<5)
425 #define ClearToBackgroundMask (1L<<6)
426 #define ChangeWindowAttributesMask (1L<<7)
428 extern int MultibufferScreenIndex;
429 extern int MultibufferWindowIndex;
431 extern RESTYPE MultibufferDrawableResType;
433 extern void MultibufferUpdate( /* pMbuffer, time */
434 #if NeedFunctionPrototypes
435 MultibufferPtr /* pMultibuffer */,
439 extern void MultibufferExpose( /* pMbuffer, pRegion */
440 #if NeedFunctionPrototypes
441 MultibufferPtr /* pMultibuffer */,
442 RegionPtr /* pRegion */
445 extern void MultibufferClobber( /* pMbuffer */
446 #if NeedFunctionPrototypes
447 MultibufferPtr /* pMultibuffer */
451 typedef struct _mbufWindow *mbufWindowPtr;
457 #define MB_DISPLAYED_BUFFER(pMBWindow) \
458 ((pMBWindow)->buffers + (pMBWindow)->displayedMultibuffer)
460 typedef struct _mbufBuffer {
461 mbufWindowPtr pMBWindow; /* associated window data */
462 Mask eventMask; /* client event mask */
463 Mask otherEventMask; /* union of other clients' event masks */
464 OtherClientsPtr otherClients; /* other clients that want events */
465 int number; /* index of this buffer into array */
466 int side; /* stero side: always Mono */
467 int clobber; /* clober state */
468 DrawablePtr pDrawable; /* associated drawable */
469 } mbufBufferRec, *mbufBufferPtr;
476 #define MB_WINDOW_PRIV(pWin) \
477 ((mbufWindowPtr)((pWin)->devPrivates[MultibufferWindowIndex].ptr))
479 typedef struct _mbufWindow {
480 WindowPtr pWindow; /* associated window */
481 int numMultibuffer; /* count of buffers */
482 mbufBufferPtr buffers; /* array of (numMultibuffer) buffers */
483 int displayedMultibuffer; /* currently active buffer */
484 int updateAction; /* Undefined, Background,
486 int updateHint; /* Frequent, Intermittent, Static */
487 int windowMode; /* always Mono */
488 TimeStamp lastUpdate; /* time of last update */
489 short x, y; /* for static gravity */
490 unsigned short width, height; /* last known window size */
499 #define MB_SCREEN_PRIV(pScreen) \
500 ((mbufScreenPtr)((pScreen)->devPrivates[MultibufferScreenIndex].ptr))
502 typedef struct _mbufScreen {
503 long mbufWindowCount; /* count of multibuffered windows */
505 /* Wrap pScreen->DestroyWindow */
506 DestroyWindowProcPtr DestroyWindow;
507 long funcsWrapped; /* flags which functions are wrapped */
509 /* Initialized by device-dependent section */
510 int nInfo; /* number of buffer info rec's */
511 xMbufBufferInfo *pInfo; /* buffer info (for Normal buffers) */
513 int (* CreateImageBuffers)(
514 #if NeedNestedPrototypes
515 WindowPtr /* pWin */,
522 void (* DestroyImageBuffers)(
523 #if NeedNestedPrototypes
527 void (* DisplayImageBuffers)(
528 #if NeedNestedPrototypes
529 ScreenPtr /* pScreen */,
530 mbufBufferPtr * /* ppMBBuffer */,
531 mbufWindowPtr * /* ppMBWindow */,
535 void (* ClearImageBufferArea)(
536 #if NeedNestedPrototypes
537 mbufBufferPtr /* pMBBuffer */,
540 unsigned short /* width */,
541 unsigned short /* height */,
545 Bool (* ChangeMBufferAttributes)( /* pMBWindow, vmask */
546 #if NeedNestedPrototypes
550 Bool (* ChangeBufferAttributes)( /* pMBBuffer, vmask */
551 #if NeedNestedPrototypes
555 void (* DeleteBufferDrawable)(
556 #if NeedNestedPrototypes
557 DrawablePtr /* pDrawable */
560 void (* WrapScreenFuncs)(
561 #if NeedNestedPrototypes
562 ScreenPtr /* pScreen */
566 #if NeedNestedPrototypes
567 ScreenPtr /* pScreen */
571 } mbufScreenRec, *mbufScreenPtr;
574 /* Privates to mbufScreenRec */
576 #ifdef _MULTIBUF_PIXMAP_
577 #define MB_SCREEN_PRIV_PIXMAP(pScreen) \
578 ((mbufPixmapPrivPtr) MB_SCREEN_PRIV((pScreen))->devPrivate.ptr)
580 typedef struct _mbufPixmapPriv
582 /* Pointers to wrapped functions */
583 PositionWindowProcPtr PositionWindow; /* pWin, x,y */
584 long funcsWrapped; /* flags which functions are wrapped */
585 } mbufPixmapPrivRec, *mbufPixmapPrivPtr;
586 #endif /* _MULTIBUF_PIXMAP_ */
589 #ifdef _MULTIBUF_BUFFER_
591 extern int frameWindowPrivateIndex;
593 #define MB_SCREEN_PRIV_BUFFER(pScreen) \
594 ((mbufBufferPrivPtr) MB_SCREEN_PRIV((pScreen))->devPrivate.ptr)
596 typedef struct _mbufBufferPriv
598 DevUnion *frameBuffer; /* Array of screen framebuffers */
599 DevUnion selectPlane; /* Plane(s) that select displayed buffer */
602 * Note: subtractRgn and unionRgn may overlap. subtractRgn is a union
603 * of all the old clipLists of the windows that are displaying
604 * the backbuffer. unionRgn is the union of all the new clipLists
605 * of the same windows.
608 RegionRec backBuffer; /* Area of screen displaying back buffer */
609 RegionRec subtractRgn; /* Regions lost to backBuffer */
610 RegionRec unionRgn; /* Regions gained by backBuffer */
611 Bool rgnChanged; /* TRUE if "backBuffer" needs to be updated */
613 void (* CopyBufferBits)(); /* pMBWindow, srcBufferNum, dstBufferNum */
614 void (* DrawSelectPlane)(); /* pScreen, selectPlane, pRegion, bufferNum */
616 /* Pointers to wrapped functions */
617 PostValidateTreeProcPtr PostValidateTree; /* pParent, pChild, kind */
618 ClipNotifyProcPtr ClipNotify; /* pWin, dx, dy */
619 WindowExposuresProcPtr WindowExposures; /* pWin, pRegion */
620 CopyWindowProcPtr CopyWindow; /* pWin, oldPt, pOldRegion */
621 ClearToBackgroundProcPtr ClearToBackground; /* pWin, x,y,w,h, sendExpose */
622 ChangeWindowAttributesProcPtr ChangeWindowAttributes; /* pWin, vmask */
623 long funcsWrapped; /* flags which functions are wrapped */
624 unsigned inClearToBackground:1; /* used by WindowExposure */
625 } mbufBufferPrivRec, *mbufBufferPrivPtr;
626 #endif /* _MULTIBUF_BUFFER_ */
628 #endif /* _MULTIBUF_SERVER_ */
629 #endif /* _MULTIBUFST_H_ */