aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/Xext/mbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/Xext/mbuf.c')
-rw-r--r--xorg-server/Xext/mbuf.c322
1 files changed, 271 insertions, 51 deletions
diff --git a/xorg-server/Xext/mbuf.c b/xorg-server/Xext/mbuf.c
index 55e732a9f..1f2497463 100644
--- a/xorg-server/Xext/mbuf.c
+++ b/xorg-server/Xext/mbuf.c
@@ -41,8 +41,9 @@ in this Software without prior written authorization from The Open Group.
#include "resource.h"
#include "opaque.h"
#include "sleepuntil.h"
-#define _MULTIBUF_SERVER_ /* don't want Xlib structures */
-#include <X11/extensions/multibufst.h>
+#include "inputstr.h"
+#include <X11/extensions/multibufconst.h>
+#include <X11/extensions/multibufproto.h>
#include <stdio.h>
#if !defined(WIN32)
@@ -57,6 +58,251 @@ in this Software without prior written authorization from The Open Group.
#define ValidEventMasks (ExposureMask|MultibufferClobberNotifyMask|MultibufferUpdateNotifyMask)
+/* The _Multibuffer and _Multibuffers structures below refer to each other,
+ * so we need this forward declaration
+ */
+typedef struct _Multibuffers *MultibuffersPtr;
+
+/*
+ * per-Multibuffer data
+ */
+typedef struct _Multibuffer {
+ MultibuffersPtr pMultibuffers; /* associated window data */
+ Mask eventMask; /* MultibufferClobberNotifyMask|ExposureMask|MultibufferUpdateNotifyMask */
+ Mask otherEventMask; /* mask of all other clients event masks */
+ OtherClients *otherClients; /* other clients that want events */
+ int number; /* index of this buffer into array */
+ int side; /* always Mono */
+ int clobber; /* Unclobbered, PartiallyClobbered, FullClobbered */
+ PixmapPtr pPixmap; /* associated pixmap */
+} MultibufferRec, *MultibufferPtr;
+
+/*
+ * per-window data
+ */
+
+typedef struct _Multibuffers {
+ WindowPtr pWindow; /* associated window */
+ int numMultibuffer; /* count of buffers */
+ int refcnt; /* ref count for delete */
+ int displayedMultibuffer; /* currently active buffer */
+ int updateAction; /* Undefined, Background, Untouched, Copied */
+ int updateHint; /* Frequent, Intermittent, Static */
+ int windowMode; /* always Mono */
+
+ TimeStamp lastUpdate; /* time of last update */
+
+ unsigned short width, height; /* last known window size */
+ short x, y; /* for static gravity */
+
+ MultibufferPtr buffers; /* array of numMultibuffer buffers */
+} MultibuffersRec;
+
+/*
+ * per-screen data
+ */
+typedef struct _MultibufferScreen {
+ PositionWindowProcPtr PositionWindow; /* pWin, x,y */
+} MultibufferScreenRec, *MultibufferScreenPtr;
+
+/*
+ * per display-image-buffers request data.
+ */
+
+typedef struct _DisplayRequest {
+ struct _DisplayRequest *next;
+ TimeStamp activateTime;
+ ClientPtr pClient;
+ XID id;
+} DisplayRequestRec, *DisplayRequestPtr;
+
+#define DestroyWindowMask (1L<<0)
+#define PositionWindowMask (1L<<1)
+#define PostValidateTreeMask (1L<<2)
+#define ClipNotifyMask (1L<<3)
+#define WindowExposuresMask (1L<<4)
+#define CopyWindowMask (1L<<5)
+#define ClearToBackgroundMask (1L<<6)
+#define ChangeWindowAttributesMask (1L<<7)
+
+extern int MultibufferScreenIndex;
+extern int MultibufferWindowIndex;
+
+extern RESTYPE MultibufferDrawableResType;
+
+extern void MultibufferUpdate( /* pMbuffer, time */
+ MultibufferPtr /* pMultibuffer */,
+ CARD32 /* time */
+ );
+extern void MultibufferExpose( /* pMbuffer, pRegion */
+ MultibufferPtr /* pMultibuffer */,
+ RegionPtr /* pRegion */
+ );
+extern void MultibufferClobber( /* pMbuffer */
+ MultibufferPtr /* pMultibuffer */
+ );
+
+typedef struct _mbufWindow *mbufWindowPtr;
+
+void DestroyImageBuffers (WindowPtr pWin);
+
+/*
+ * per-buffer data
+ */
+
+#define MB_DISPLAYED_BUFFER(pMBWindow) \
+ ((pMBWindow)->buffers + (pMBWindow)->displayedMultibuffer)
+
+typedef struct _mbufBuffer {
+ mbufWindowPtr pMBWindow; /* associated window data */
+ Mask eventMask; /* client event mask */
+ Mask otherEventMask; /* union of other clients' event masks */
+ OtherClientsPtr otherClients; /* other clients that want events */
+ int number; /* index of this buffer into array */
+ int side; /* stero side: always Mono */
+ int clobber; /* clober state */
+ DrawablePtr pDrawable; /* associated drawable */
+} mbufBufferRec, *mbufBufferPtr;
+
+
+/*
+ * per-window data
+ */
+
+#define MB_WINDOW_PRIV(pWin) \
+ ((mbufWindowPtr)((pWin)->devPrivates[MultibufferWindowIndex].ptr))
+
+typedef struct _mbufWindow {
+ WindowPtr pWindow; /* associated window */
+ int numMultibuffer; /* count of buffers */
+ mbufBufferPtr buffers; /* array of (numMultibuffer) buffers */
+ int displayedMultibuffer; /* currently active buffer */
+ int updateAction; /* Undefined, Background,
+ Untouched, Copied */
+ int updateHint; /* Frequent, Intermittent, Static */
+ int windowMode; /* always Mono */
+ TimeStamp lastUpdate; /* time of last update */
+ short x, y; /* for static gravity */
+ unsigned short width, height; /* last known window size */
+ DevUnion devPrivate;
+} mbufWindowRec;
+
+
+/*
+ * per-screen data
+ */
+
+#define MB_SCREEN_PRIV(pScreen) \
+ ((mbufScreenPtr)((pScreen)->devPrivates[MultibufferScreenIndex].ptr))
+
+typedef struct _mbufScreen {
+ long mbufWindowCount; /* count of multibuffered windows */
+
+ /* Wrap pScreen->DestroyWindow */
+ DestroyWindowProcPtr DestroyWindow;
+ long funcsWrapped; /* flags which functions are wrapped */
+
+ /* Initialized by device-dependent section */
+ int nInfo; /* number of buffer info rec's */
+ xMbufBufferInfo *pInfo; /* buffer info (for Normal buffers) */
+
+ int (* CreateImageBuffers)(
+ WindowPtr /* pWin */,
+ int /* nbuf */,
+ XID * /* ids */,
+ int /* action */,
+ int /* hint */
+ );
+ void (* DestroyImageBuffers)(
+ WindowPtr /* pWin */
+ );
+ void (* DisplayImageBuffers)(
+ ScreenPtr /* pScreen */,
+ mbufBufferPtr * /* ppMBBuffer */,
+ mbufWindowPtr * /* ppMBWindow */,
+ int /* nbuf */
+ );
+ void (* ClearImageBufferArea)(
+ mbufBufferPtr /* pMBBuffer */,
+ short /* x */,
+ short /* y */,
+ unsigned short /* width */,
+ unsigned short /* height */,
+ Bool /* exposures */
+ );
+ Bool (* ChangeMBufferAttributes)( /* pMBWindow, vmask */
+ /* FIXME */
+ );
+ Bool (* ChangeBufferAttributes)( /* pMBBuffer, vmask */
+ /* FIXME */
+ );
+ void (* DeleteBufferDrawable)(
+ DrawablePtr /* pDrawable */
+ );
+ void (* WrapScreenFuncs)(
+ ScreenPtr /* pScreen */
+ );
+ void (* ResetProc)(
+ ScreenPtr /* pScreen */
+ );
+ DevUnion devPrivate;
+} mbufScreenRec, *mbufScreenPtr;
+
+
+/* Privates to mbufScreenRec */
+
+#ifdef _MULTIBUF_PIXMAP_
+#define MB_SCREEN_PRIV_PIXMAP(pScreen) \
+ ((mbufPixmapPrivPtr) MB_SCREEN_PRIV((pScreen))->devPrivate.ptr)
+
+typedef struct _mbufPixmapPriv
+{
+ /* Pointers to wrapped functions */
+ PositionWindowProcPtr PositionWindow; /* pWin, x,y */
+ long funcsWrapped; /* flags which functions are wrapped */
+} mbufPixmapPrivRec, *mbufPixmapPrivPtr;
+#endif /* _MULTIBUF_PIXMAP_ */
+
+
+#ifdef _MULTIBUF_BUFFER_
+
+extern int frameWindowPrivateIndex;
+
+#define MB_SCREEN_PRIV_BUFFER(pScreen) \
+ ((mbufBufferPrivPtr) MB_SCREEN_PRIV((pScreen))->devPrivate.ptr)
+
+typedef struct _mbufBufferPriv
+{
+ DevUnion *frameBuffer; /* Array of screen framebuffers */
+ DevUnion selectPlane; /* Plane(s) that select displayed buffer */
+
+ /*
+ * Note: subtractRgn and unionRgn may overlap. subtractRgn is a union
+ * of all the old clipLists of the windows that are displaying
+ * the backbuffer. unionRgn is the union of all the new clipLists
+ * of the same windows.
+ */
+
+ RegionRec backBuffer; /* Area of screen displaying back buffer */
+ RegionRec subtractRgn; /* Regions lost to backBuffer */
+ RegionRec unionRgn; /* Regions gained by backBuffer */
+ Bool rgnChanged; /* TRUE if "backBuffer" needs to be updated */
+
+ void (* CopyBufferBits)(); /* pMBWindow, srcBufferNum, dstBufferNum */
+ void (* DrawSelectPlane)(); /* pScreen, selectPlane, pRegion, bufferNum */
+
+ /* Pointers to wrapped functions */
+ PostValidateTreeProcPtr PostValidateTree; /* pParent, pChild, kind */
+ ClipNotifyProcPtr ClipNotify; /* pWin, dx, dy */
+ WindowExposuresProcPtr WindowExposures; /* pWin, pRegion */
+ CopyWindowProcPtr CopyWindow; /* pWin, oldPt, pOldRegion */
+ ClearToBackgroundProcPtr ClearToBackground; /* pWin, x,y,w,h, sendExpose */
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes; /* pWin, vmask */
+ long funcsWrapped; /* flags which functions are wrapped */
+ unsigned inClearToBackground:1; /* used by WindowExposure */
+} mbufBufferPrivRec, *mbufBufferPrivPtr;
+#endif /* _MULTIBUF_BUFFER_ */
+
static int MultibufferEventBase;
static int MultibufferErrorBase;
static int MultibufferScreenPrivKeyIndex;
@@ -495,6 +741,7 @@ ProcDisplayImageBuffers (client)
int i, j;
CARD32 minDelay;
TimeStamp activateTime, bufferTime;
+ int rc;
REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq);
@@ -516,9 +763,9 @@ ProcDisplayImageBuffers (client)
activateTime.milliseconds = 0;
for (i = 0; i < nbuf; i++)
{
- pMultibuffer[i] = (MultibufferPtr) LookupIDByType (ids[i],
-MultibufferResType);
- if (!pMultibuffer[i])
+ rc = dixLookupResourceByType(&pMultibuffer[i], ids[i],
+ MultibufferResType, client, DixUseAccess);
+ if (rc != Success)
{
xfree(ppMultibuffers);
xfree(pMultibuffer);
@@ -589,8 +836,9 @@ ProcSetMBufferAttributes (client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
if (rc != Success)
return rc;
- pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType);
- if (!pMultibuffers)
+ rc = dixLookupResourceByType(&pMultibuffers, pWin->drawable.id,
+ MultibufferResType, client, DixSetAttrAccess);
+ if (rc != Success)
return BadMatch;
len = stuff->length - bytes_to_int32(sizeof (xMbufSetMBufferAttributesReq));
vmask = stuff->valueMask;
@@ -641,8 +889,9 @@ ProcGetMBufferAttributes (client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
if (rc != Success)
return rc;
- pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType);
- if (!pMultibuffers)
+ rc = dixLookupResourceByType(&pMultibuffers, pWin->drawable.id,
+ MultibufferResType, client, DixGetAttrAccess);
+ if (rc != Success)
return BadAccess;
ids = xalloc (pMultibuffers->numMultibuffer * sizeof (XID));
if (!ids)
@@ -682,10 +931,13 @@ ProcSetBufferAttributes (client)
XID *vlist;
Mask eventMask;
int result;
+ int rc;
REQUEST_AT_LEAST_SIZE (xMbufSetBufferAttributesReq);
- pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType);
- if (!pMultibuffer)
+
+ rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer,
+ MultibufferResType, client, DixSetAttrAccess);
+ if (rc != Success)
return MultibufferErrorBase + MultibufferBadBuffer;
len = stuff->length - bytes_to_int32(sizeof (xMbufSetBufferAttributesReq));
vmask = stuff->valueMask;
@@ -722,10 +974,12 @@ ProcGetBufferAttributes (client)
xMbufGetBufferAttributesReply rep;
OtherClientsPtr other;
int n;
+ int rc;
REQUEST_SIZE_MATCH (xMbufGetBufferAttributesReq);
- pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType);
- if (!pMultibuffer)
+ rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer,
+ MultibufferResType, client, DixGetAttrAccess);
+ if (rc != Success)
return MultibufferErrorBase + MultibufferBadBuffer;
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
@@ -832,10 +1086,12 @@ ProcClearImageBufferArea (client)
int width, height;
DrawablePtr pDrawable;
ScreenPtr pScreen;
+ int rc;
REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq);
- pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType);
- if (!pMultibuffer)
+ rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer,
+ MultibufferResType, client, DixWriteAccess);
+ if (rc != Success)
return MultibufferErrorBase + MultibufferBadBuffer;
if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
{
@@ -1253,42 +1509,6 @@ GetBufferPointer (pWin, i)
return (DrawablePtr) pMultibuffers->buffers[i].pPixmap;
}
-int
-DisplayImageBuffers (ids, nbuf)
- XID *ids;
- int nbuf;
-{
- MultibufferPtr *pMultibuffer;
- MultibuffersPtr *pMultibuffers;
- int i, j;
-
- pMultibuffer = xalloc (nbuf * sizeof *pMultibuffer +
- nbuf * sizeof *pMultibuffers);
- if (!pMultibuffer)
- return BadAlloc;
- pMultibuffers = (MultibuffersPtr *) (pMultibuffer + nbuf);
- for (i = 0; i < nbuf; i++)
- {
- pMultibuffer[i] = (MultibufferPtr) LookupIDByType (ids[i], MultibufferResType);
- if (!pMultibuffer[i])
- {
- xfree (pMultibuffer);
- return MultibufferErrorBase + MultibufferBadBuffer;
- }
- pMultibuffers[i] = pMultibuffer[i]->pMultibuffers;
- for (j = 0; j < i; j++)
- if (pMultibuffers[i] == pMultibuffers[j])
- {
- xfree (pMultibuffer);
- return BadMatch;
- }
- }
- PerformDisplayRequest (pMultibuffers, pMultibuffer, nbuf);
- xfree (pMultibuffer);
- return Success;
-}
-
-
static Bool
QueueDisplayRequest (client, activateTime)
ClientPtr client;