(submit/cleanup-shm-dispatch) 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:
Enrico Weigelt, metux IT consult 2024-07-03 16:45:06 +02:00
parent 90891ab7c6
commit f026976a10

View File

@ -109,6 +109,7 @@ static void SShmCompletionEvent(xShmCompletionEvent *from,
xShmCompletionEvent *to); xShmCompletionEvent *to);
static Bool ShmDestroyPixmap(PixmapPtr pPixmap); static Bool ShmDestroyPixmap(PixmapPtr pPixmap);
static int ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff);
static unsigned char ShmReqCode; static unsigned char ShmReqCode;
int ShmCompletionCode; int ShmCompletionCode;
@ -515,16 +516,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))
@ -614,7 +612,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;
@ -625,9 +623,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;
@ -732,16 +727,19 @@ ProcShmGetImage(ClientPtr client)
return Success; return Success;
} }
#ifdef PANORAMIX
static int static int
ProcPanoramiXShmPutImage(ClientPtr client) ProcShmPutImage(ClientPtr client)
{ {
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
#ifdef PANORAMIX
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);
@ -768,16 +766,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 /* PANORAMIX */
} }
static int static int
ProcPanoramiXShmGetImage(ClientPtr client) ProcShmGetImage(ClientPtr client)
{ {
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
#ifdef PANORAMIX
PanoramiXRes *draw; PanoramiXRes *draw;
DrawablePtr *drawables; DrawablePtr *drawables;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -788,9 +793,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;
@ -803,7 +807,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)
@ -914,24 +918,31 @@ ProcPanoramiXShmGetImage(ClientPtr client)
WriteToClient(client, sizeof(xShmGetImageReply), &xgi); WriteToClient(client, sizeof(xShmGetImageReply), &xgi);
return Success; return Success;
#else
return ShmGetImage(client, stuff);
#endif /* PANORAMIX */
} }
static int static int
ProcPanoramiXShmCreatePixmap(ClientPtr client) ProcShmCreatePixmap(ClientPtr client)
{ {
REQUEST(xShmCreatePixmapReq);
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
#ifdef PANORAMIX
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;
@ -1027,8 +1038,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 /* PANORAMIX */
} }
#endif
static PixmapPtr static PixmapPtr
fbShmCreatePixmap(ScreenPtr pScreen, fbShmCreatePixmap(ScreenPtr pScreen,
@ -1051,7 +1064,7 @@ fbShmCreatePixmap(ScreenPtr pScreen,
} }
static int static int
ProcShmCreatePixmap(ClientPtr client) ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff)
{ {
PixmapPtr pMap; PixmapPtr pMap;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -1059,12 +1072,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;
@ -1349,22 +1359,10 @@ ProcShmDispatch(ClientPtr client)
case X_ShmDetach: case X_ShmDetach:
return ProcShmDetach(client); return ProcShmDetach(client);
case X_ShmPutImage: case X_ShmPutImage:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShmPutImage(client);
#endif
return ProcShmPutImage(client); return ProcShmPutImage(client);
case X_ShmGetImage: case X_ShmGetImage:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShmGetImage(client);
#endif
return ProcShmGetImage(client); return ProcShmGetImage(client);
case X_ShmCreatePixmap: case X_ShmCreatePixmap:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShmCreatePixmap(client);
#endif
return ProcShmCreatePixmap(client); return ProcShmCreatePixmap(client);
#ifdef SHM_FD_PASSING #ifdef SHM_FD_PASSING
case X_ShmAttachFd: case X_ShmAttachFd: