Xext: shm: simplify dispatcher
These dispatcher functions are much more complex than they're usually are (just switch/case statement). Bring them in line with the standard scheme used in the Xserver, so further steps become easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
850da1ad5f
commit
c67b05e653
77
Xext/shm.c
77
Xext/shm.c
|
@ -106,6 +106,8 @@ static void ShmResetProc(ExtensionEntry *extEntry);
|
||||||
static void SShmCompletionEvent(xShmCompletionEvent *from,
|
static void SShmCompletionEvent(xShmCompletionEvent *from,
|
||||||
xShmCompletionEvent *to);
|
xShmCompletionEvent *to);
|
||||||
|
|
||||||
|
static int ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff);
|
||||||
|
|
||||||
static unsigned char ShmReqCode;
|
static unsigned char ShmReqCode;
|
||||||
int ShmCompletionCode;
|
int ShmCompletionCode;
|
||||||
int BadShmSegCode;
|
int BadShmSegCode;
|
||||||
|
@ -490,16 +492,13 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcShmPutImage(ClientPtr client)
|
ShmPutImage(ClientPtr client, xShmPutImageReq *stuff)
|
||||||
{
|
{
|
||||||
GCPtr pGC;
|
GCPtr pGC;
|
||||||
DrawablePtr pDraw;
|
DrawablePtr pDraw;
|
||||||
long length;
|
long length;
|
||||||
ShmDescPtr shmdesc;
|
ShmDescPtr shmdesc;
|
||||||
|
|
||||||
REQUEST(xShmPutImageReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xShmPutImageReq);
|
|
||||||
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
||||||
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
|
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
|
||||||
if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
|
if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
|
||||||
|
@ -589,7 +588,7 @@ ProcShmPutImage(ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcShmGetImage(ClientPtr client)
|
ShmGetImage(ClientPtr client, xShmGetImageReq *stuff)
|
||||||
{
|
{
|
||||||
DrawablePtr pDraw;
|
DrawablePtr pDraw;
|
||||||
long lenPer = 0, length;
|
long lenPer = 0, length;
|
||||||
|
@ -600,9 +599,6 @@ ProcShmGetImage(ClientPtr client)
|
||||||
RegionPtr pVisibleRegion = NULL;
|
RegionPtr pVisibleRegion = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST(xShmGetImageReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xShmGetImageReq);
|
|
||||||
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
|
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
|
||||||
client->errorValue = stuff->format;
|
client->errorValue = stuff->format;
|
||||||
return BadValue;
|
return BadValue;
|
||||||
|
@ -707,16 +703,19 @@ ProcShmGetImage(ClientPtr client)
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XINERAMA
|
|
||||||
static int
|
static int
|
||||||
ProcPanoramiXShmPutImage(ClientPtr client)
|
ProcShmPutImage(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
REQUEST(xShmPutImageReq);
|
||||||
|
REQUEST_SIZE_MATCH(xShmPutImageReq);
|
||||||
|
|
||||||
|
#ifdef XINERAMA
|
||||||
int j, result, orig_x, orig_y;
|
int j, result, orig_x, orig_y;
|
||||||
PanoramiXRes *draw, *gc;
|
PanoramiXRes *draw, *gc;
|
||||||
Bool sendEvent, isRoot;
|
Bool sendEvent, isRoot;
|
||||||
|
|
||||||
REQUEST(xShmPutImageReq);
|
if (noPanoramiXExtension)
|
||||||
REQUEST_SIZE_MATCH(xShmPutImageReq);
|
return ShmPutImage(client, stuff);
|
||||||
|
|
||||||
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
|
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
|
||||||
XRC_DRAWABLE, client, DixWriteAccess);
|
XRC_DRAWABLE, client, DixWriteAccess);
|
||||||
|
@ -743,16 +742,23 @@ ProcPanoramiXShmPutImage(ClientPtr client)
|
||||||
stuff->dstX = orig_x - screenInfo.screens[j]->x;
|
stuff->dstX = orig_x - screenInfo.screens[j]->x;
|
||||||
stuff->dstY = orig_y - screenInfo.screens[j]->y;
|
stuff->dstY = orig_y - screenInfo.screens[j]->y;
|
||||||
}
|
}
|
||||||
result = ProcShmPutImage(client);
|
result = ShmPutImage(client, stuff);
|
||||||
if (result != Success)
|
if (result != Success)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
return ShmPutImage(client, stuff);
|
||||||
|
#endif /* XINERAMA */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcPanoramiXShmGetImage(ClientPtr client)
|
ProcShmGetImage(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
REQUEST(xShmGetImageReq);
|
||||||
|
REQUEST_SIZE_MATCH(xShmGetImageReq);
|
||||||
|
|
||||||
|
#ifdef XINERAMA
|
||||||
PanoramiXRes *draw;
|
PanoramiXRes *draw;
|
||||||
DrawablePtr pDraw;
|
DrawablePtr pDraw;
|
||||||
xShmGetImageReply xgi;
|
xShmGetImageReply xgi;
|
||||||
|
@ -762,9 +768,8 @@ ProcPanoramiXShmGetImage(ClientPtr client)
|
||||||
long lenPer = 0, length, widthBytesLine;
|
long lenPer = 0, length, widthBytesLine;
|
||||||
Bool isRoot;
|
Bool isRoot;
|
||||||
|
|
||||||
REQUEST(xShmGetImageReq);
|
if (noPanoramiXExtension)
|
||||||
|
return ShmGetImage(client, stuff);
|
||||||
REQUEST_SIZE_MATCH(xShmGetImageReq);
|
|
||||||
|
|
||||||
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
|
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
|
||||||
client->errorValue = stuff->format;
|
client->errorValue = stuff->format;
|
||||||
|
@ -777,7 +782,7 @@ ProcPanoramiXShmGetImage(ClientPtr client)
|
||||||
return (rc == BadValue) ? BadDrawable : rc;
|
return (rc == BadValue) ? BadDrawable : rc;
|
||||||
|
|
||||||
if (draw->type == XRT_PIXMAP)
|
if (draw->type == XRT_PIXMAP)
|
||||||
return ProcShmGetImage(client);
|
return ShmGetImage(client, stuff);
|
||||||
|
|
||||||
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess);
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
|
@ -888,24 +893,31 @@ ProcPanoramiXShmGetImage(ClientPtr client)
|
||||||
WriteToClient(client, sizeof(xShmGetImageReply), &xgi);
|
WriteToClient(client, sizeof(xShmGetImageReply), &xgi);
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
#else
|
||||||
|
return ShmGetImage(client, stuff);
|
||||||
|
#endif /* XINERAMA */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcPanoramiXShmCreatePixmap(ClientPtr client)
|
ProcShmCreatePixmap(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
REQUEST(xShmCreatePixmapReq);
|
||||||
|
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
|
||||||
|
|
||||||
|
#ifdef XINERAMA
|
||||||
|
if (noPanoramiXExtension)
|
||||||
|
return ShmCreatePixmap(client, stuff);
|
||||||
|
|
||||||
ScreenPtr pScreen = NULL;
|
ScreenPtr pScreen = NULL;
|
||||||
PixmapPtr pMap = NULL;
|
PixmapPtr pMap = NULL;
|
||||||
DrawablePtr pDraw;
|
DrawablePtr pDraw;
|
||||||
DepthPtr pDepth;
|
DepthPtr pDepth;
|
||||||
int i, j, result, rc;
|
int i, j, result, rc;
|
||||||
ShmDescPtr shmdesc;
|
ShmDescPtr shmdesc;
|
||||||
|
|
||||||
REQUEST(xShmCreatePixmapReq);
|
|
||||||
unsigned int width, height, depth;
|
unsigned int width, height, depth;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
PanoramiXRes *newPix;
|
PanoramiXRes *newPix;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
|
|
||||||
client->errorValue = stuff->pid;
|
client->errorValue = stuff->pid;
|
||||||
if (!sharedPixmaps)
|
if (!sharedPixmaps)
|
||||||
return BadImplementation;
|
return BadImplementation;
|
||||||
|
@ -1001,8 +1013,10 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
|
||||||
AddResource(stuff->pid, XRT_PIXMAP, newPix);
|
AddResource(stuff->pid, XRT_PIXMAP, newPix);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
#else
|
||||||
|
return ShmCreatePixmap(client, stuff);
|
||||||
#endif /* XINERAMA */
|
#endif /* XINERAMA */
|
||||||
|
}
|
||||||
|
|
||||||
static PixmapPtr
|
static PixmapPtr
|
||||||
fbShmCreatePixmap(ScreenPtr pScreen,
|
fbShmCreatePixmap(ScreenPtr pScreen,
|
||||||
|
@ -1025,7 +1039,7 @@ fbShmCreatePixmap(ScreenPtr pScreen,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcShmCreatePixmap(ClientPtr client)
|
ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff)
|
||||||
{
|
{
|
||||||
PixmapPtr pMap;
|
PixmapPtr pMap;
|
||||||
DrawablePtr pDraw;
|
DrawablePtr pDraw;
|
||||||
|
@ -1033,12 +1047,9 @@ ProcShmCreatePixmap(ClientPtr client)
|
||||||
int i, rc;
|
int i, rc;
|
||||||
ShmDescPtr shmdesc;
|
ShmDescPtr shmdesc;
|
||||||
ShmScrPrivateRec *screen_priv;
|
ShmScrPrivateRec *screen_priv;
|
||||||
|
|
||||||
REQUEST(xShmCreatePixmapReq);
|
|
||||||
unsigned int width, height, depth;
|
unsigned int width, height, depth;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
|
|
||||||
client->errorValue = stuff->pid;
|
client->errorValue = stuff->pid;
|
||||||
if (!sharedPixmaps)
|
if (!sharedPixmaps)
|
||||||
return BadImplementation;
|
return BadImplementation;
|
||||||
|
@ -1322,22 +1333,10 @@ ProcShmDispatch(ClientPtr client)
|
||||||
case X_ShmDetach:
|
case X_ShmDetach:
|
||||||
return ProcShmDetach(client);
|
return ProcShmDetach(client);
|
||||||
case X_ShmPutImage:
|
case X_ShmPutImage:
|
||||||
#ifdef XINERAMA
|
|
||||||
if (!noPanoramiXExtension)
|
|
||||||
return ProcPanoramiXShmPutImage(client);
|
|
||||||
#endif /* XINERAMA */
|
|
||||||
return ProcShmPutImage(client);
|
return ProcShmPutImage(client);
|
||||||
case X_ShmGetImage:
|
case X_ShmGetImage:
|
||||||
#ifdef XINERAMA
|
|
||||||
if (!noPanoramiXExtension)
|
|
||||||
return ProcPanoramiXShmGetImage(client);
|
|
||||||
#endif /* XINERAMA */
|
|
||||||
return ProcShmGetImage(client);
|
return ProcShmGetImage(client);
|
||||||
case X_ShmCreatePixmap:
|
case X_ShmCreatePixmap:
|
||||||
#ifdef XINERAMA
|
|
||||||
if (!noPanoramiXExtension)
|
|
||||||
return ProcPanoramiXShmCreatePixmap(client);
|
|
||||||
#endif /* XINERAMA */
|
|
||||||
return ProcShmCreatePixmap(client);
|
return ProcShmCreatePixmap(client);
|
||||||
#ifdef SHM_FD_PASSING
|
#ifdef SHM_FD_PASSING
|
||||||
case X_ShmAttachFd:
|
case X_ShmAttachFd:
|
||||||
|
|
Loading…
Reference in New Issue