dbestruct.h revision 05b261ec
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/Xdbeproto.h> 41#include "windowstr.h" 42 43 44/* DEFINES */ 45 46#define DBE_SCREEN_PRIV(pScreen) \ 47 ((dbeScreenPrivIndex < 0) ? \ 48 NULL : \ 49 ((DbeScreenPrivPtr)((pScreen)->devPrivates[dbeScreenPrivIndex].ptr))) 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(pWindow)\ 67 ((dbeWindowPrivIndex < 0) ? \ 68 NULL : \ 69 ((DbeWindowPrivPtr)(pWindow->devPrivates[dbeWindowPrivIndex].ptr))) 70 71/* Initial size of the buffer ID array in the window priv. */ 72#define DBE_INIT_MAX_IDS 2 73 74/* Reallocation increment for the buffer ID array. */ 75#define DBE_INCR_MAX_IDS 4 76 77/* Marker for free elements in the buffer ID array. */ 78#define DBE_FREE_ID_ELEMENT 0 79 80 81/* TYPEDEFS */ 82 83/* Record used to pass swap information between DIX and DDX swapping 84 * procedures. 85 */ 86typedef struct _DbeSwapInfoRec 87{ 88 WindowPtr pWindow; 89 unsigned char swapAction; 90 91} DbeSwapInfoRec, *DbeSwapInfoPtr; 92 93/* 94 ****************************************************************************** 95 ** Per-window data 96 ****************************************************************************** 97 */ 98 99typedef struct _DbeWindowPrivRec 100{ 101 /* A pointer to the window with which the DBE window private (buffer) is 102 * associated. 103 */ 104 WindowPtr pWindow; 105 106 /* Last known swap action for this buffer. Legal values for this field 107 * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied. 108 */ 109 unsigned char swapAction; 110 111 /* Last known buffer size. 112 */ 113 unsigned short width, height; 114 115 /* Coordinates used for static gravity when the window is positioned. 116 */ 117 short x, y; 118 119 /* Number of XIDs associated with this buffer. 120 */ 121 int nBufferIDs; 122 123 /* Capacity of the current buffer ID array, IDs. */ 124 int maxAvailableIDs; 125 126 /* Pointer to the array of buffer IDs. This initially points to initIDs. 127 * When the static limit of the initIDs array is reached, the array is 128 * reallocated and this pointer is set to the new array instead of initIDs. 129 */ 130 XID *IDs; 131 132 /* Initial array of buffer IDs. We are defining the XID array within the 133 * window priv to optimize for data locality. In most cases, only one 134 * buffer will be associated with a window. Having the array declared 135 * here can prevent us from accessing the data in another memory page, 136 * possibly resulting in a page swap and loss of performance. Initially we 137 * will use this array to store buffer IDs. For situations where we have 138 * more IDs than can fit in this static array, we will allocate a larger 139 * array to use, possibly suffering a performance loss. 140 */ 141 XID initIDs[DBE_INIT_MAX_IDS]; 142 143 /* Device-specific private information. 144 */ 145 DevUnion *devPrivates; 146 147} DbeWindowPrivRec, *DbeWindowPrivPtr; 148 149 150/* 151 ****************************************************************************** 152 ** Per-screen data 153 ****************************************************************************** 154 */ 155 156typedef struct _DbeScreenPrivRec 157{ 158 /* Info for creating window privs */ 159 int winPrivPrivLen; /* Length of privs in DbeWindowPrivRec */ 160 unsigned int *winPrivPrivSizes; /* Array of private record sizes */ 161 unsigned int totalWinPrivSize; /* PrivRec + size of all priv priv ptrs */ 162 163 /* Resources created by DIX to be used by DDX */ 164 RESTYPE dbeDrawableResType; 165 RESTYPE dbeWindowPrivResType; 166 167 /* Private indices created by DIX to be used by DDX */ 168 int dbeScreenPrivIndex; 169 int dbeWindowPrivIndex; 170 171 /* Wrapped functions 172 * It is the responsibilty of the DDX layer to wrap PositionWindow(). 173 * DbeExtensionInit wraps DestroyWindow(). 174 */ 175 PositionWindowProcPtr PositionWindow; 176 DestroyWindowProcPtr DestroyWindow; 177 178 /* Per-screen DIX routines */ 179 Bool (*SetupBackgroundPainter)( 180 WindowPtr /*pWin*/, 181 GCPtr /*pGC*/ 182); 183 DbeWindowPrivPtr (*AllocWinPriv)( 184 ScreenPtr /*pScreen*/ 185); 186 int (*AllocWinPrivPrivIndex)( 187 void 188); 189 Bool (*AllocWinPrivPriv)( 190 ScreenPtr /*pScreen*/, 191 int /*index*/, 192 unsigned /*amount*/ 193); 194 195 /* Per-screen DDX routines */ 196 Bool (*GetVisualInfo)( 197 ScreenPtr /*pScreen*/, 198 XdbeScreenVisualInfo * /*pVisInfo*/ 199); 200 int (*AllocBackBufferName)( 201 WindowPtr /*pWin*/, 202 XID /*bufId*/, 203 int /*swapAction*/ 204); 205 int (*SwapBuffers)( 206 ClientPtr /*client*/, 207 int * /*pNumWindows*/, 208 DbeSwapInfoPtr /*swapInfo*/ 209); 210 void (*BeginIdiom)( 211 ClientPtr /*client*/ 212); 213 void (*EndIdiom)( 214 ClientPtr /*client*/ 215); 216 void (*WinPrivDelete)( 217 DbeWindowPrivPtr /*pDbeWindowPriv*/, 218 XID /*bufId*/ 219); 220 void (*ResetProc)( 221 ScreenPtr /*pScreen*/ 222); 223 224 /* Device-specific private information. 225 */ 226 DevUnion *devPrivates; 227 228} DbeScreenPrivRec, *DbeScreenPrivPtr; 229 230#endif /* DBE_STRUCT_H */ 231