aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dbe
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-06-11 12:14:52 +0000
committermarha <marha@users.sourceforge.net>2010-06-11 12:14:52 +0000
commit4c61bf84b11e26e6f22648668c95ea760a379163 (patch)
tree0ac762ab2815eae283dded7447ad7cb5a54b926a /xorg-server/dbe
parente1dabd2ce8be0d70c6c15353b58de256129dfd1f (diff)
downloadvcxsrv-4c61bf84b11e26e6f22648668c95ea760a379163.tar.gz
vcxsrv-4c61bf84b11e26e6f22648668c95ea760a379163.tar.bz2
vcxsrv-4c61bf84b11e26e6f22648668c95ea760a379163.zip
xserver git update 11/6/2010
Diffstat (limited to 'xorg-server/dbe')
-rw-r--r--xorg-server/dbe/dbe.c108
-rw-r--r--xorg-server/dbe/dbestruct.h436
-rw-r--r--xorg-server/dbe/midbe.c68
-rw-r--r--xorg-server/dbe/midbe.h105
4 files changed, 348 insertions, 369 deletions
diff --git a/xorg-server/dbe/dbe.c b/xorg-server/dbe/dbe.c
index 80383bfc9..d1074a2fb 100644
--- a/xorg-server/dbe/dbe.c
+++ b/xorg-server/dbe/dbe.c
@@ -57,15 +57,13 @@
/* GLOBALS */
-/* These are static globals copied to DBE's screen private for use by DDX */
-static int dbeScreenPrivKeyIndex;
-static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKeyIndex;
-static int dbeWindowPrivKeyIndex;
-static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKeyIndex;
+/* These are globals for use by DDX */
+DevPrivateKeyRec dbeScreenPrivKeyRec;
+DevPrivateKeyRec dbeWindowPrivKeyRec;
-/* These are static globals copied to DBE's screen private for use by DDX */
-static RESTYPE dbeDrawableResType;
-static RESTYPE dbeWindowPrivResType;
+/* These are globals for use by DDX */
+RESTYPE dbeDrawableResType;
+RESTYPE dbeWindowPrivResType;
/* Used to generate DBE's BadBuffer error. */
static int dbeErrorBase;
@@ -201,7 +199,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
/* The window must be InputOutput. */
if (pWin->drawable.class != InputOutput)
{
- return(BadMatch);
+ return BadMatch;
}
/* The swap action must be valid. */
@@ -211,7 +209,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
(swapAction != XdbeUntouched ) &&
(swapAction != XdbeCopied ))
{
- return(BadValue);
+ return BadValue;
}
/* The id must be in range and not already in use. */
@@ -222,12 +220,12 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
*/
pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
if (!pDbeScreenPriv->GetVisualInfo)
- return(BadMatch); /* screen doesn't support double buffering */
+ return BadMatch; /* screen doesn't support double buffering */
if (!(*pDbeScreenPriv->GetVisualInfo)(pWin->drawable.pScreen, &scrVisInfo))
{
/* GetVisualInfo() failed to allocate visual info data. */
- return(BadAlloc);
+ return BadAlloc;
}
/* See if the window's visual is on the list. */
@@ -245,7 +243,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
if (!visualMatched)
{
- return(BadMatch);
+ return BadMatch;
}
if ((pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)) == NULL)
@@ -254,9 +252,9 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
* Allocate a window priv.
*/
- pDbeWindowPriv = calloc(1, sizeof(DbeWindowPrivRec));
+ pDbeWindowPriv = dixAllocateObjectWithPrivates(DbeWindowPrivRec, PRIVATE_DBE_WINDOW);
if (!pDbeWindowPriv)
- return(BadAlloc);
+ return BadAlloc;
/* Fill out window priv information. */
pDbeWindowPriv->pWindow = pWin;
@@ -323,7 +321,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
(pDbeWindowPriv->maxAvailableIDs+DBE_INCR_MAX_IDS)*sizeof(XID));
if (!pDbeWindowPriv->IDs)
{
- return(BadAlloc);
+ return BadAlloc;
}
memset(&pDbeWindowPriv->IDs[pDbeWindowPriv->nBufferIDs], 0,
(pDbeWindowPriv->maxAvailableIDs + DBE_INCR_MAX_IDS -
@@ -379,12 +377,12 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
/* Set swap action on all calls. */
pDbeWindowPriv->swapAction = stuff->swapAction;
- return(status);
+ return status;
out_free:
dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, NULL);
free(pDbeWindowPriv);
- return (status);
+ return status;
} /* ProcDbeAllocateBackBufferName() */
@@ -447,12 +445,12 @@ ProcDbeDeallocateBackBufferName(ClientPtr client)
{
/* We did not find the ID in the ID list. */
client->errorValue = stuff->buffer;
- return(dbeErrorBase + DbeBadBuffer);
+ return dbeErrorBase + DbeBadBuffer;
}
FreeResource(stuff->buffer, RT_NONE);
- return(Success);
+ return Success;
} /* ProcDbeDeallocateBackBufferName() */
@@ -498,7 +496,7 @@ ProcDbeSwapBuffers(ClientPtr client)
if (nStuff == 0)
{
- return(Success);
+ return Success;
}
if (nStuff > UINT32_MAX / sizeof(DbeSwapInfoRec))
@@ -511,7 +509,7 @@ ProcDbeSwapBuffers(ClientPtr client)
swapInfo = (DbeSwapInfoPtr)malloc(nStuff * sizeof(DbeSwapInfoRec));
if (swapInfo == NULL)
{
- return(BadAlloc);
+ return BadAlloc;
}
@@ -531,7 +529,7 @@ ProcDbeSwapBuffers(ClientPtr client)
if (DBE_WINDOW_PRIV(pWin) == NULL)
{
free(swapInfo);
- return(BadMatch);
+ return BadMatch;
}
/* Each window must only be specified once - BadMatch. */
@@ -540,7 +538,7 @@ ProcDbeSwapBuffers(ClientPtr client)
if (dbeSwapInfo[i].window == dbeSwapInfo[j].window)
{
free(swapInfo);
- return(BadMatch);
+ return BadMatch;
}
}
@@ -551,7 +549,7 @@ ProcDbeSwapBuffers(ClientPtr client)
(dbeSwapInfo[i].swapAction != XdbeCopied ))
{
free(swapInfo);
- return(BadValue);
+ return BadValue;
}
/* Everything checks out OK. Fill in the swap info array. */
@@ -581,12 +579,12 @@ ProcDbeSwapBuffers(ClientPtr client)
if (error != Success)
{
free(swapInfo);
- return(error);
+ return error;
}
}
free(swapInfo);
- return(Success);
+ return Success;
} /* ProcDbeSwapBuffers() */
@@ -628,7 +626,7 @@ ProcDbeBeginIdiom(ClientPtr client)
}
}
- return(Success);
+ return Success;
} /* ProcDbeBeginIdiom() */
@@ -675,7 +673,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
if (!(pDrawables = (DrawablePtr *)malloc(stuff->n *
sizeof(DrawablePtr))))
{
- return(BadAlloc);
+ return BadAlloc;
}
drawables = (Drawable *)&stuff[1];
@@ -695,12 +693,9 @@ ProcDbeGetVisualInfo(ClientPtr client)
if (!(pScrVisInfo = (XdbeScreenVisualInfo *)malloc(count *
sizeof(XdbeScreenVisualInfo))))
{
- if (pDrawables)
- {
- free(pDrawables);
- }
+ free(pDrawables);
- return(BadAlloc);
+ return BadAlloc;
}
length = 0;
@@ -724,10 +719,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
}
/* Free pDrawables if we needed to allocate it above. */
- if (pDrawables)
- {
- free(pDrawables);
- }
+ free(pDrawables);
return (rc == Success) ? BadAlloc : rc;
}
@@ -805,10 +797,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
}
free(pScrVisInfo);
- if (pDrawables)
- {
- free(pDrawables);
- }
+ free(pDrawables);
return Success;
@@ -905,7 +894,7 @@ ProcDbeDispatch(ClientPtr client)
return(ProcDbeBeginIdiom(client));
case X_DbeEndIdiom:
- return(Success);
+ return Success;
case X_DbeGetVisualInfo:
return(ProcDbeGetVisualInfo(client));
@@ -914,7 +903,7 @@ ProcDbeDispatch(ClientPtr client)
return(ProcDbeGetBackBufferAttributes(client));
default:
- return(BadRequest);
+ return BadRequest;
}
} /* ProcDbeDispatch() */
@@ -1206,7 +1195,7 @@ SProcDbeDispatch(ClientPtr client)
return(SProcDbeBeginIdiom(client));
case X_DbeEndIdiom:
- return(Success);
+ return Success;
case X_DbeGetVisualInfo:
return(SProcDbeGetVisualInfo(client));
@@ -1215,7 +1204,7 @@ SProcDbeDispatch(ClientPtr client)
return(SProcDbeGetBackBufferAttributes(client));
default:
- return (BadRequest);
+ return BadRequest;
}
} /* SProcDbeDispatch() */
@@ -1280,7 +1269,7 @@ DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC)
default:
/* pWin->backgroundState == None */
- return(FALSE);
+ return FALSE;
}
return ChangeGC(NullClient, pGC, gcmask, gcvalues) == 0;
@@ -1306,7 +1295,7 @@ DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC)
static int
DbeDrawableDelete(pointer pDrawable, XID id)
{
- return(Success);
+ return Success;
} /* DbeDrawableDelete() */
@@ -1346,7 +1335,7 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
if (i == pDbeWindowPriv->nBufferIDs)
{
/* We did not find the ID in the array. We should never get here. */
- return(BadValue);
+ return BadValue;
}
/* Remove the ID from the array. */
@@ -1410,11 +1399,10 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
NULL);
/* We are done with the window priv. */
- dixFreePrivates(pDbeWindowPriv->devPrivates);
- free(pDbeWindowPriv);
+ dixFreeObjectWithPrivates(pDbeWindowPriv, PRIVATE_DBE_WINDOW);
}
- return(Success);
+ return Success;
} /* DbeWindowPrivDelete() */
@@ -1535,7 +1523,7 @@ DbeDestroyWindow(WindowPtr pWin)
**************************************************************************
*/
- return(ret);
+ return ret;
} /* DbeDestroyWindow() */
@@ -1576,8 +1564,10 @@ DbeExtensionInit(void)
if (!dbeWindowPrivResType)
return;
- if (!dixRegisterPrivateOffset(dbeDrawableResType,
- offsetof(PixmapRec, devPrivates)))
+ if (!dixRegisterPrivateKey(&dbeScreenPrivKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
+ if (!dixRegisterPrivateKey(&dbeWindowPrivKeyRec, PRIVATE_WINDOW, 0))
return;
for (i = 0; i < screenInfo.numScreens; i++)
@@ -1606,14 +1596,6 @@ DbeExtensionInit(void)
dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv);
- /* Copy the resource types */
- pDbeScreenPriv->dbeDrawableResType = dbeDrawableResType;
- pDbeScreenPriv->dbeWindowPrivResType = dbeWindowPrivResType;
-
- /* Copy the private indices */
- pDbeScreenPriv->dbeScreenPrivKey = dbeScreenPrivKey;
- pDbeScreenPriv->dbeWindowPrivKey = dbeWindowPrivKey;
-
{
/* We don't have DDX support for DBE anymore */
diff --git a/xorg-server/dbe/dbestruct.h b/xorg-server/dbe/dbestruct.h
index ba6b56d79..089719ba7 100644
--- a/xorg-server/dbe/dbestruct.h
+++ b/xorg-server/dbe/dbestruct.h
@@ -1,222 +1,214 @@
-/******************************************************************************
- *
- * Copyright (c) 1994, 1995 Hewlett-Packard Company
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the Hewlett-Packard
- * Company shall not be used in advertising or otherwise to promote the
- * sale, use or other dealings in this Software without prior written
- * authorization from the Hewlett-Packard Company.
- *
- * Header file for DIX-related DBE
- *
- *****************************************************************************/
-
-#ifndef DBE_STRUCT_H
-#define DBE_STRUCT_H
-
-
-/* INCLUDES */
-
-#define NEED_DBE_PROTOCOL
-#include <X11/extensions/dbeproto.h>
-#include "windowstr.h"
-#include "privates.h"
-
-typedef struct
-{
- VisualID visual; /* one visual ID that supports double-buffering */
- int depth; /* depth of visual in bits */
- int perflevel; /* performance level of visual */
-}
-XdbeVisualInfo;
-
-typedef struct
-{
- int count; /* number of items in visual_depth */
- XdbeVisualInfo *visinfo; /* list of visuals & depths for scrn */
-}
-XdbeScreenVisualInfo;
-
-/* DEFINES */
-
-#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey))
-
-#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
- DBE_SCREEN_PRIV((pDrawable)->pScreen)
-
-#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
- DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
-
-#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
- DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
-
-#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
- DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
-
-#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
- DBE_SCREEN_PRIV((pGC)->pScreen)
-
-#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \
- dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey))
-
-/* Initial size of the buffer ID array in the window priv. */
-#define DBE_INIT_MAX_IDS 2
-
-/* Reallocation increment for the buffer ID array. */
-#define DBE_INCR_MAX_IDS 4
-
-/* Marker for free elements in the buffer ID array. */
-#define DBE_FREE_ID_ELEMENT 0
-
-extern _X_EXPORT void DbeExtensionInit (void);
-
-/* TYPEDEFS */
-
-/* Record used to pass swap information between DIX and DDX swapping
- * procedures.
- */
-typedef struct _DbeSwapInfoRec
-{
- WindowPtr pWindow;
- unsigned char swapAction;
-
-} DbeSwapInfoRec, *DbeSwapInfoPtr;
-
-/*
- ******************************************************************************
- ** Per-window data
- ******************************************************************************
- */
-
-typedef struct _DbeWindowPrivRec
-{
- /* A pointer to the window with which the DBE window private (buffer) is
- * associated.
- */
- WindowPtr pWindow;
-
- /* Last known swap action for this buffer. Legal values for this field
- * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
- */
- unsigned char swapAction;
-
- /* Last known buffer size.
- */
- unsigned short width, height;
-
- /* Coordinates used for static gravity when the window is positioned.
- */
- short x, y;
-
- /* Number of XIDs associated with this buffer.
- */
- int nBufferIDs;
-
- /* Capacity of the current buffer ID array, IDs. */
- int maxAvailableIDs;
-
- /* Pointer to the array of buffer IDs. This initially points to initIDs.
- * When the static limit of the initIDs array is reached, the array is
- * reallocated and this pointer is set to the new array instead of initIDs.
- */
- XID *IDs;
-
- /* Initial array of buffer IDs. We are defining the XID array within the
- * window priv to optimize for data locality. In most cases, only one
- * buffer will be associated with a window. Having the array declared
- * here can prevent us from accessing the data in another memory page,
- * possibly resulting in a page swap and loss of performance. Initially we
- * will use this array to store buffer IDs. For situations where we have
- * more IDs than can fit in this static array, we will allocate a larger
- * array to use, possibly suffering a performance loss.
- */
- XID initIDs[DBE_INIT_MAX_IDS];
-
- /* Device-specific private information.
- */
- PrivateRec *devPrivates;
-
-} DbeWindowPrivRec, *DbeWindowPrivPtr;
-
-
-/*
- ******************************************************************************
- ** Per-screen data
- ******************************************************************************
- */
-
-typedef struct _DbeScreenPrivRec
-{
- /* Resources created by DIX to be used by DDX */
- RESTYPE dbeDrawableResType;
- RESTYPE dbeWindowPrivResType;
-
- /* Private indices created by DIX to be used by DDX */
- DevPrivateKey dbeScreenPrivKey;
- DevPrivateKey dbeWindowPrivKey;
-
- /* Wrapped functions
- * It is the responsibilty of the DDX layer to wrap PositionWindow().
- * DbeExtensionInit wraps DestroyWindow().
- */
- PositionWindowProcPtr PositionWindow;
- DestroyWindowProcPtr DestroyWindow;
-
- /* Per-screen DIX routines */
- Bool (*SetupBackgroundPainter)(
- WindowPtr /*pWin*/,
- GCPtr /*pGC*/
-);
-
- /* Per-screen DDX routines */
- Bool (*GetVisualInfo)(
- ScreenPtr /*pScreen*/,
- XdbeScreenVisualInfo * /*pVisInfo*/
-);
- int (*AllocBackBufferName)(
- WindowPtr /*pWin*/,
- XID /*bufId*/,
- int /*swapAction*/
-);
- int (*SwapBuffers)(
- ClientPtr /*client*/,
- int * /*pNumWindows*/,
- DbeSwapInfoPtr /*swapInfo*/
-);
- void (*BeginIdiom)(
- ClientPtr /*client*/
-);
- void (*EndIdiom)(
- ClientPtr /*client*/
-);
- void (*WinPrivDelete)(
- DbeWindowPrivPtr /*pDbeWindowPriv*/,
- XID /*bufId*/
-);
- void (*ResetProc)(
- ScreenPtr /*pScreen*/
-);
-
-} DbeScreenPrivRec, *DbeScreenPrivPtr;
-
-#endif /* DBE_STRUCT_H */
+/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * Header file for DIX-related DBE
+ *
+ *****************************************************************************/
+
+#ifndef DBE_STRUCT_H
+#define DBE_STRUCT_H
+
+
+/* INCLUDES */
+
+#define NEED_DBE_PROTOCOL
+#include <X11/extensions/dbeproto.h>
+#include "windowstr.h"
+#include "privates.h"
+
+typedef struct
+{
+ VisualID visual; /* one visual ID that supports double-buffering */
+ int depth; /* depth of visual in bits */
+ int perflevel; /* performance level of visual */
+}
+XdbeVisualInfo;
+
+typedef struct
+{
+ int count; /* number of items in visual_depth */
+ XdbeVisualInfo *visinfo; /* list of visuals & depths for scrn */
+}
+XdbeScreenVisualInfo;
+
+/* DEFINES */
+
+#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey))
+
+#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
+ DBE_SCREEN_PRIV((pDrawable)->pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
+ DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
+ DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
+ DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
+ DBE_SCREEN_PRIV((pGC)->pScreen)
+
+#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey))
+
+/* Initial size of the buffer ID array in the window priv. */
+#define DBE_INIT_MAX_IDS 2
+
+/* Reallocation increment for the buffer ID array. */
+#define DBE_INCR_MAX_IDS 4
+
+/* Marker for free elements in the buffer ID array. */
+#define DBE_FREE_ID_ELEMENT 0
+
+extern _X_EXPORT void DbeExtensionInit (void);
+
+/* TYPEDEFS */
+
+/* Record used to pass swap information between DIX and DDX swapping
+ * procedures.
+ */
+typedef struct _DbeSwapInfoRec
+{
+ WindowPtr pWindow;
+ unsigned char swapAction;
+
+} DbeSwapInfoRec, *DbeSwapInfoPtr;
+
+/*
+ ******************************************************************************
+ ** Per-window data
+ ******************************************************************************
+ */
+
+typedef struct _DbeWindowPrivRec
+{
+ /* A pointer to the window with which the DBE window private (buffer) is
+ * associated.
+ */
+ WindowPtr pWindow;
+
+ /* Last known swap action for this buffer. Legal values for this field
+ * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
+ */
+ unsigned char swapAction;
+
+ /* Last known buffer size.
+ */
+ unsigned short width, height;
+
+ /* Coordinates used for static gravity when the window is positioned.
+ */
+ short x, y;
+
+ /* Number of XIDs associated with this buffer.
+ */
+ int nBufferIDs;
+
+ /* Capacity of the current buffer ID array, IDs. */
+ int maxAvailableIDs;
+
+ /* Pointer to the array of buffer IDs. This initially points to initIDs.
+ * When the static limit of the initIDs array is reached, the array is
+ * reallocated and this pointer is set to the new array instead of initIDs.
+ */
+ XID *IDs;
+
+ /* Initial array of buffer IDs. We are defining the XID array within the
+ * window priv to optimize for data locality. In most cases, only one
+ * buffer will be associated with a window. Having the array declared
+ * here can prevent us from accessing the data in another memory page,
+ * possibly resulting in a page swap and loss of performance. Initially we
+ * will use this array to store buffer IDs. For situations where we have
+ * more IDs than can fit in this static array, we will allocate a larger
+ * array to use, possibly suffering a performance loss.
+ */
+ XID initIDs[DBE_INIT_MAX_IDS];
+
+ /* Device-specific private information.
+ */
+ PrivateRec *devPrivates;
+
+} DbeWindowPrivRec, *DbeWindowPrivPtr;
+
+
+/*
+ ******************************************************************************
+ ** Per-screen data
+ ******************************************************************************
+ */
+
+typedef struct _DbeScreenPrivRec
+{
+ /* Wrapped functions
+ * It is the responsibilty of the DDX layer to wrap PositionWindow().
+ * DbeExtensionInit wraps DestroyWindow().
+ */
+ PositionWindowProcPtr PositionWindow;
+ DestroyWindowProcPtr DestroyWindow;
+
+ /* Per-screen DIX routines */
+ Bool (*SetupBackgroundPainter)(
+ WindowPtr /*pWin*/,
+ GCPtr /*pGC*/
+);
+
+ /* Per-screen DDX routines */
+ Bool (*GetVisualInfo)(
+ ScreenPtr /*pScreen*/,
+ XdbeScreenVisualInfo * /*pVisInfo*/
+);
+ int (*AllocBackBufferName)(
+ WindowPtr /*pWin*/,
+ XID /*bufId*/,
+ int /*swapAction*/
+);
+ int (*SwapBuffers)(
+ ClientPtr /*client*/,
+ int * /*pNumWindows*/,
+ DbeSwapInfoPtr /*swapInfo*/
+);
+ void (*BeginIdiom)(
+ ClientPtr /*client*/
+);
+ void (*EndIdiom)(
+ ClientPtr /*client*/
+);
+ void (*WinPrivDelete)(
+ DbeWindowPrivPtr /*pDbeWindowPriv*/,
+ XID /*bufId*/
+);
+ void (*ResetProc)(
+ ScreenPtr /*pScreen*/
+);
+
+} DbeScreenPrivRec, *DbeScreenPrivPtr;
+
+#endif /* DBE_STRUCT_H */
diff --git a/xorg-server/dbe/midbe.c b/xorg-server/dbe/midbe.c
index cba386c0b..15ae85b36 100644
--- a/xorg-server/dbe/midbe.c
+++ b/xorg-server/dbe/midbe.c
@@ -58,14 +58,8 @@
#include <stdio.h>
-static int miDbeWindowPrivPrivKeyIndex;
-static DevPrivateKey miDbeWindowPrivPrivKey = &miDbeWindowPrivPrivKeyIndex;
-static RESTYPE dbeDrawableResType;
-static RESTYPE dbeWindowPrivResType;
-static int dbeScreenPrivKeyIndex;
-static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKeyIndex;
-static int dbeWindowPrivKeyIndex;
-static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKeyIndex;
+static DevPrivateKeyRec miDbeWindowPrivPrivKeyRec;
+#define miDbeWindowPrivPrivKey (&miDbeWindowPrivPrivKeyRec)
/******************************************************************************
@@ -102,7 +96,7 @@ miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo *pScrVisInfo)
/* Allocate an array of XdbeVisualInfo items. */
if (!(visInfo = (XdbeVisualInfo *)malloc(count * sizeof(XdbeVisualInfo))))
{
- return(FALSE); /* memory alloc failure */
+ return FALSE; /* memory alloc failure */
}
for (i = 0, k = 0; i < pScreen->numDepths; i++)
@@ -131,7 +125,7 @@ miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo *pScrVisInfo)
pScrVisInfo->count = count;
pScrVisInfo->visinfo = visInfo;
- return(TRUE); /* success */
+ return TRUE; /* success */
} /* miDbeGetVisualInfo() */
@@ -181,7 +175,7 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
pDbeWindowPriv->height,
pWin->drawable.depth, 0)))
{
- return(BadAlloc);
+ return BadAlloc;
}
/* Get a back pixmap. */
@@ -191,7 +185,7 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
pWin->drawable.depth, 0)))
{
(*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer);
- return(BadAlloc);
+ return BadAlloc;
}
/* Security creation/labeling check. */
@@ -241,12 +235,12 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
if (!AddResource(bufId, dbeDrawableResType,
(pointer)pDbeWindowPrivPriv->pBackBuffer))
{
- return(BadAlloc);
+ return BadAlloc;
}
}
- return(Success);
+ return Success;
} /* miDbeAllocBackBufferName() */
@@ -415,7 +409,7 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
FreeScratchGC(pGC);
- return(Success);
+ return Success;
} /* miSwapBuffers() */
@@ -577,13 +571,13 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
{
- return(ret);
+ return ret;
}
if (pDbeWindowPriv->width == pWin->drawable.width &&
pDbeWindowPriv->height == pWin->drawable.height)
{
- return(ret);
+ return ret;
}
width = pWin->drawable.width;
@@ -684,7 +678,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
}
FreeScratchGC(pGC);
- return(FALSE);
+ return FALSE;
}
else
@@ -695,25 +689,33 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
- ValidateGC((DrawablePtr)pFrontBuffer, pGC);
/* I suppose this could avoid quite a bit of work if
* it computed the minimal area required.
*/
+ ValidateGC(&pFrontBuffer->drawable, pGC);
if (clear)
{
(*pGC->ops->PolyFillRect)((DrawablePtr)pFrontBuffer, pGC, 1,
&clearRect);
- (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
- &clearRect);
- }
-
- /* Copy the contents of the old DBE pixmaps to the new pixmaps. */
+ }
+ /* Copy the contents of the old front pixmap to the new one. */
if (pWin->bitGravity != ForgetGravity)
{
(*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
(DrawablePtr)pFrontBuffer, pGC, sourcex,
sourcey, savewidth, saveheight, destx, desty);
+ }
+
+ ValidateGC(&pBackBuffer->drawable, pGC);
+ if (clear)
+ {
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
+ &clearRect);
+ }
+ /* Copy the contents of the old back pixmap to the new one. */
+ if (pWin->bitGravity != ForgetGravity)
+ {
(*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
(DrawablePtr)pBackBuffer, pGC, sourcex,
sourcey, savewidth, saveheight, destx, desty);
@@ -735,7 +737,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
FreeScratchGC(pGC);
}
- return(ret);
+ return ret;
} /* miDbePositionWindow() */
@@ -779,17 +781,9 @@ miDbeResetProc(ScreenPtr pScreen)
Bool
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
{
- /* Copy resource types created by DIX */
- dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType;
- dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
-
- /* Copy private indices created by DIX */
- dbeScreenPrivKey = pDbeScreenPriv->dbeScreenPrivKey;
- dbeWindowPrivKey = pDbeScreenPriv->dbeWindowPrivKey;
-
- if (!dixRequestPrivate(miDbeWindowPrivPrivKey,
- sizeof(MiDbeWindowPrivPrivRec)))
- return(FALSE);
+ if (!dixRegisterPrivateKey(&miDbeWindowPrivPrivKeyRec, PRIVATE_DBE_WINDOW,
+ sizeof(MiDbeWindowPrivPrivRec)))
+ return FALSE;
/* Wrap functions. */
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
@@ -804,6 +798,6 @@ miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
pDbeScreenPriv->ResetProc = miDbeResetProc;
pDbeScreenPriv->WinPrivDelete = miDbeWinPrivDelete;
- return(TRUE);
+ return TRUE;
} /* miDbeInit() */
diff --git a/xorg-server/dbe/midbe.h b/xorg-server/dbe/midbe.h
index 007f2e37b..4f09bf432 100644
--- a/xorg-server/dbe/midbe.h
+++ b/xorg-server/dbe/midbe.h
@@ -1,47 +1,58 @@
-/******************************************************************************
- * Copyright (c) 1994, 1995 Hewlett-Packard Company
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the Hewlett-Packard
- * Company shall not be used in advertising or otherwise to promote the
- * sale, use or other dealings in this Software without prior written
- * authorization from the Hewlett-Packard Company.
- *
- * Header file for users of machine-independent DBE code
- *
- *****************************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef MIDBE_H
-#define MIDBE_H
-
-/* EXTERNS */
-
-extern Bool miDbeInit(
- ScreenPtr pScreen,
- DbeScreenPrivPtr pDbeScreenPriv
-);
-
-#endif /* MIDBE_H */
-
+/******************************************************************************
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * Header file for users of machine-independent DBE code
+ *
+ *****************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef MIDBE_H
+#define MIDBE_H
+
+#include "privates.h"
+
+/* EXTERNS */
+
+extern Bool miDbeInit(
+ ScreenPtr pScreen,
+ DbeScreenPrivPtr pDbeScreenPriv
+);
+
+extern DevPrivateKeyRec dbeScreenPrivKeyRec;
+#define dbeScreenPrivKey (&dbeScreenPrivKeyRec)
+
+extern DevPrivateKeyRec dbeWindowPrivKeyRec;
+#define dbeWindowPrivKey (&dbeWindowPrivKeyRec)
+
+extern RESTYPE dbeDrawableResType;
+extern RESTYPE dbeWindowPrivResType;
+
+#endif /* MIDBE_H */
+