dbestruct.h revision 684baedf
1/******************************************************************************
2 *
3 * Copyright (c) 1994, 1995  Hewlett-Packard Company
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Except as contained in this notice, the name of the Hewlett-Packard
25 * Company shall not be used in advertising or otherwise to promote the
26 * sale, use or other dealings in this Software without prior written
27 * authorization from the Hewlett-Packard Company.
28 *
29 *     Header file for DIX-related DBE
30 *
31 *****************************************************************************/
32
33#ifndef DBE_STRUCT_H
34#define DBE_STRUCT_H
35
36
37/* INCLUDES */
38
39#define NEED_DBE_PROTOCOL
40#include <X11/extensions/Xdbe.h>
41#include <X11/extensions/dbeproto.h>
42#include "windowstr.h"
43#include "privates.h"
44
45
46/* DEFINES */
47
48#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \
49    dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey))
50
51#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
52    DBE_SCREEN_PRIV((pDrawable)->pScreen)
53
54#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
55    DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
56
57#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
58    DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
59
60#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
61    DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
62
63#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
64    DBE_SCREEN_PRIV((pGC)->pScreen)
65
66#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \
67    dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey))
68
69/* Initial size of the buffer ID array in the window priv. */
70#define DBE_INIT_MAX_IDS	2
71
72/* Reallocation increment for the buffer ID array. */
73#define DBE_INCR_MAX_IDS	4
74
75/* Marker for free elements in the buffer ID array. */
76#define DBE_FREE_ID_ELEMENT	0
77
78extern void DbeExtensionInit (void);
79
80/* TYPEDEFS */
81
82/* Record used to pass swap information between DIX and DDX swapping
83 * procedures.
84 */
85typedef struct _DbeSwapInfoRec
86{
87    WindowPtr		pWindow;
88    unsigned char	swapAction;
89
90} DbeSwapInfoRec, *DbeSwapInfoPtr;
91
92/*
93 ******************************************************************************
94 ** Per-window data
95 ******************************************************************************
96 */
97
98typedef struct _DbeWindowPrivRec
99{
100    /* A pointer to the window with which the DBE window private (buffer) is
101     * associated.
102     */
103    WindowPtr		pWindow;
104
105    /* Last known swap action for this buffer.  Legal values for this field
106     * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
107     */
108    unsigned char	swapAction;
109
110    /* Last known buffer size.
111     */
112    unsigned short	width, height;
113
114    /* Coordinates used for static gravity when the window is positioned.
115     */
116    short		x, y;
117
118    /* Number of XIDs associated with this buffer.
119     */
120    int			nBufferIDs;
121
122    /* Capacity of the current buffer ID array, IDs. */
123    int			maxAvailableIDs;
124
125    /* Pointer to the array of buffer IDs.  This initially points to initIDs.
126     * When the static limit of the initIDs array is reached, the array is
127     * reallocated and this pointer is set to the new array instead of initIDs.
128     */
129    XID			*IDs;
130
131    /* Initial array of buffer IDs.  We are defining the XID array within the
132     * window priv to optimize for data locality.  In most cases, only one
133     * buffer will be associated with a window.  Having the array declared
134     * here can prevent us from accessing the data in another memory page,
135     * possibly resulting in a page swap and loss of performance.  Initially we
136     * will use this array to store buffer IDs.  For situations where we have
137     * more IDs than can fit in this static array, we will allocate a larger
138     * array to use, possibly suffering a performance loss.
139     */
140    XID			initIDs[DBE_INIT_MAX_IDS];
141
142    /* Device-specific private information.
143     */
144    PrivateRec		*devPrivates;
145
146} DbeWindowPrivRec, *DbeWindowPrivPtr;
147
148
149/*
150 ******************************************************************************
151 ** Per-screen data
152 ******************************************************************************
153 */
154
155typedef struct _DbeScreenPrivRec
156{
157    /* Resources created by DIX to be used by DDX */
158    RESTYPE	dbeDrawableResType;
159    RESTYPE	dbeWindowPrivResType;
160
161    /* Private indices created by DIX to be used by DDX */
162    DevPrivateKey dbeScreenPrivKey;
163    DevPrivateKey dbeWindowPrivKey;
164
165    /* Wrapped functions
166     * It is the responsibilty of the DDX layer to wrap PositionWindow().
167     * DbeExtensionInit wraps DestroyWindow().
168     */
169    PositionWindowProcPtr PositionWindow;
170    DestroyWindowProcPtr  DestroyWindow;
171
172    /* Per-screen DIX routines */
173    Bool	(*SetupBackgroundPainter)(
174		WindowPtr /*pWin*/,
175		GCPtr /*pGC*/
176);
177
178    /* Per-screen DDX routines */
179    Bool	(*GetVisualInfo)(
180		ScreenPtr /*pScreen*/,
181		XdbeScreenVisualInfo * /*pVisInfo*/
182);
183    int		(*AllocBackBufferName)(
184		WindowPtr /*pWin*/,
185		XID /*bufId*/,
186		int /*swapAction*/
187);
188    int		(*SwapBuffers)(
189		ClientPtr /*client*/,
190		int * /*pNumWindows*/,
191		DbeSwapInfoPtr /*swapInfo*/
192);
193    void	(*BeginIdiom)(
194		ClientPtr /*client*/
195);
196    void	(*EndIdiom)(
197		ClientPtr /*client*/
198);
199    void	(*WinPrivDelete)(
200		DbeWindowPrivPtr /*pDbeWindowPriv*/,
201		XID /*bufId*/
202);
203    void	(*ResetProc)(
204		ScreenPtr /*pScreen*/
205);
206
207    /* Device-specific private information.
208     */
209    PrivateRec	*devPrivates;
210
211} DbeScreenPrivRec, *DbeScreenPrivPtr;
212
213#endif /* DBE_STRUCT_H */
214