dix: write out X_GetImage reply directly
No need for using a complex callback machinery, if we just move the little pieces of byte-swapping directly into the request handler. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									3cab73e790
								
							
						
					
					
						commit
						b3db55be06
					
				| 
						 | 
					@ -1960,7 +1960,6 @@ PanoramiXGetImage(ClientPtr client)
 | 
				
			||||||
    DrawablePtr drawables[MAXSCREENS];
 | 
					    DrawablePtr drawables[MAXSCREENS];
 | 
				
			||||||
    DrawablePtr pDraw;
 | 
					    DrawablePtr pDraw;
 | 
				
			||||||
    PanoramiXRes *draw;
 | 
					    PanoramiXRes *draw;
 | 
				
			||||||
    xGetImageReply xgi;
 | 
					 | 
				
			||||||
    Bool isRoot;
 | 
					    Bool isRoot;
 | 
				
			||||||
    char *pBuf;
 | 
					    char *pBuf;
 | 
				
			||||||
    int i, x, y, w, h, format, rc;
 | 
					    int i, x, y, w, h, format, rc;
 | 
				
			||||||
| 
						 | 
					@ -2034,12 +2033,7 @@ PanoramiXGetImage(ClientPtr client)
 | 
				
			||||||
                                              IncludeInferiors);
 | 
					                                              IncludeInferiors);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    xgi = (xGetImageReply) {
 | 
					
 | 
				
			||||||
        .type = X_Reply,
 | 
					 | 
				
			||||||
        .sequenceNumber = client->sequence,
 | 
					 | 
				
			||||||
        .visual = wVisual(((WindowPtr) pDraw)),
 | 
					 | 
				
			||||||
        .depth = pDraw->depth
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    if (format == ZPixmap) {
 | 
					    if (format == ZPixmap) {
 | 
				
			||||||
        widthBytesLine = PixmapBytePad(w, pDraw->depth);
 | 
					        widthBytesLine = PixmapBytePad(w, pDraw->depth);
 | 
				
			||||||
        length = widthBytesLine * h;
 | 
					        length = widthBytesLine * h;
 | 
				
			||||||
| 
						 | 
					@ -2053,7 +2047,13 @@ PanoramiXGetImage(ClientPtr client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    xgi.length = bytes_to_int32(length);
 | 
					    xGetImageReply rep = {
 | 
				
			||||||
 | 
					        .type = X_Reply,
 | 
				
			||||||
 | 
					        .sequenceNumber = client->sequence,
 | 
				
			||||||
 | 
					        .visual = wVisual(((WindowPtr) pDraw)),
 | 
				
			||||||
 | 
					        .depth = pDraw->depth,
 | 
				
			||||||
 | 
					        .length = bytes_to_int32(length),
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (widthBytesLine == 0 || h == 0)
 | 
					    if (widthBytesLine == 0 || h == 0)
 | 
				
			||||||
        linesPerBuf = 0;
 | 
					        linesPerBuf = 0;
 | 
				
			||||||
| 
						 | 
					@ -2067,7 +2067,12 @@ PanoramiXGetImage(ClientPtr client)
 | 
				
			||||||
    if (!(pBuf = xallocarray(linesPerBuf, widthBytesLine)))
 | 
					    if (!(pBuf = xallocarray(linesPerBuf, widthBytesLine)))
 | 
				
			||||||
        return BadAlloc;
 | 
					        return BadAlloc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
 | 
					    if (client->swapped) {
 | 
				
			||||||
 | 
					        swaps(&rep.sequenceNumber);
 | 
				
			||||||
 | 
					        swapl(&rep.length);
 | 
				
			||||||
 | 
					        swapl(&rep.visual);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    WriteToClient(client, sizeof(rep), &rep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (linesPerBuf == 0) {
 | 
					    if (linesPerBuf == 0) {
 | 
				
			||||||
        /* nothing to do */
 | 
					        /* nothing to do */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2159,7 +2159,6 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 | 
				
			||||||
    long widthBytesLine, length;
 | 
					    long widthBytesLine, length;
 | 
				
			||||||
    Mask plane = 0;
 | 
					    Mask plane = 0;
 | 
				
			||||||
    char *pBuf;
 | 
					    char *pBuf;
 | 
				
			||||||
    xGetImageReply xgi;
 | 
					 | 
				
			||||||
    RegionPtr pVisibleRegion = NULL;
 | 
					    RegionPtr pVisibleRegion = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((format != XYPixmap) && (format != ZPixmap)) {
 | 
					    if ((format != XYPixmap) && (format != ZPixmap)) {
 | 
				
			||||||
| 
						 | 
					@ -2170,7 +2169,10 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 | 
				
			||||||
    if (rc != Success)
 | 
					    if (rc != Success)
 | 
				
			||||||
        return rc;
 | 
					        return rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    memset(&xgi, 0, sizeof(xGetImageReply));
 | 
					    xGetImageReply rep = {
 | 
				
			||||||
 | 
					        .type = X_Reply,
 | 
				
			||||||
 | 
					        .sequenceNumber = client->sequence,
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    relx = x;
 | 
					    relx = x;
 | 
				
			||||||
    rely = y;
 | 
					    rely = y;
 | 
				
			||||||
| 
						 | 
					@ -2207,11 +2209,11 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 | 
				
			||||||
            pBoundingDraw = (DrawablePtr) pDraw->pScreen->root;
 | 
					            pBoundingDraw = (DrawablePtr) pDraw->pScreen->root;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        xgi.visual = wVisual(pWin);
 | 
					        rep.visual = wVisual(pWin);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
        pBoundingDraw = pDraw;
 | 
					        pBoundingDraw = pDraw;
 | 
				
			||||||
        xgi.visual = None;
 | 
					        rep.visual = None;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* "If the drawable is a pixmap, the given rectangle must be wholly
 | 
					    /* "If the drawable is a pixmap, the given rectangle must be wholly
 | 
				
			||||||
| 
						 | 
					@ -2229,9 +2231,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 | 
				
			||||||
        rely < 0 || rely + height > (int) pBoundingDraw->height)
 | 
					        rely < 0 || rely + height > (int) pBoundingDraw->height)
 | 
				
			||||||
        return BadMatch;
 | 
					        return BadMatch;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    xgi.type = X_Reply;
 | 
					    rep.depth = pDraw->depth;
 | 
				
			||||||
    xgi.sequenceNumber = client->sequence;
 | 
					 | 
				
			||||||
    xgi.depth = pDraw->depth;
 | 
					 | 
				
			||||||
    if (format == ZPixmap) {
 | 
					    if (format == ZPixmap) {
 | 
				
			||||||
        widthBytesLine = PixmapBytePad(width, pDraw->depth);
 | 
					        widthBytesLine = PixmapBytePad(width, pDraw->depth);
 | 
				
			||||||
        length = widthBytesLine * height;
 | 
					        length = widthBytesLine * height;
 | 
				
			||||||
| 
						 | 
					@ -2246,9 +2246,8 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    xgi.length = length;
 | 
					    rep.length = bytes_to_int32(length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    xgi.length = bytes_to_int32(xgi.length);
 | 
					 | 
				
			||||||
    if (widthBytesLine == 0 || height == 0)
 | 
					    if (widthBytesLine == 0 || height == 0)
 | 
				
			||||||
        linesPerBuf = 0;
 | 
					        linesPerBuf = 0;
 | 
				
			||||||
    else if (widthBytesLine >= IMAGE_BUFSIZE)
 | 
					    else if (widthBytesLine >= IMAGE_BUFSIZE)
 | 
				
			||||||
| 
						 | 
					@ -2273,7 +2272,13 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!(pBuf = calloc(1, length)))
 | 
					    if (!(pBuf = calloc(1, length)))
 | 
				
			||||||
        return BadAlloc;
 | 
					        return BadAlloc;
 | 
				
			||||||
    WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
 | 
					
 | 
				
			||||||
 | 
					    if (client->swapped) {
 | 
				
			||||||
 | 
					        swaps(&rep.sequenceNumber);
 | 
				
			||||||
 | 
					        swapl(&rep.length);
 | 
				
			||||||
 | 
					        swapl(&rep.visual);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    WriteToClient(client, sizeof(rep), &rep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pDraw->type == DRAWABLE_WINDOW) {
 | 
					    if (pDraw->type == DRAWABLE_WINDOW) {
 | 
				
			||||||
        pVisibleRegion = &((WindowPtr) pDraw)->borderClip;
 | 
					        pVisibleRegion = &((WindowPtr) pDraw)->borderClip;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -424,16 +424,6 @@ SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep)
 | 
				
			||||||
    WriteToClient(pClient, size, pRep);
 | 
					    WriteToClient(pClient, size, pRep);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void _X_COLD
 | 
					 | 
				
			||||||
SGetImageReply(ClientPtr pClient, int size, xGetImageReply * pRep)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    swaps(&pRep->sequenceNumber);
 | 
					 | 
				
			||||||
    swapl(&pRep->length);
 | 
					 | 
				
			||||||
    swapl(&pRep->visual);
 | 
					 | 
				
			||||||
    WriteToClient(pClient, size, pRep);
 | 
					 | 
				
			||||||
    /* Fortunately, image doesn't need swapping */
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void _X_COLD
 | 
					void _X_COLD
 | 
				
			||||||
SListInstalledColormapsReply(ClientPtr pClient, int size,
 | 
					SListInstalledColormapsReply(ClientPtr pClient, int size,
 | 
				
			||||||
                             xListInstalledColormapsReply * pRep)
 | 
					                             xListInstalledColormapsReply * pRep)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -785,7 +785,7 @@ ReplySwapPtr ReplySwapVector[256] = {
 | 
				
			||||||
    ReplyNotSwappd,                             /* 70 */
 | 
					    ReplyNotSwappd,                             /* 70 */
 | 
				
			||||||
    ReplyNotSwappd,
 | 
					    ReplyNotSwappd,
 | 
				
			||||||
    ReplyNotSwappd,
 | 
					    ReplyNotSwappd,
 | 
				
			||||||
    (ReplySwapPtr) SGetImageReply,
 | 
					    ReplyNotSwappd,
 | 
				
			||||||
    ReplyNotSwappd,
 | 
					    ReplyNotSwappd,
 | 
				
			||||||
    ReplyNotSwappd,                             /* 75 */
 | 
					    ReplyNotSwappd,                             /* 75 */
 | 
				
			||||||
    ReplyNotSwappd,
 | 
					    ReplyNotSwappd,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,10 +115,6 @@ extern void SGetFontPathReply(ClientPtr /* pClient */ ,
 | 
				
			||||||
                              int /* size */ ,
 | 
					                              int /* size */ ,
 | 
				
			||||||
                              xGetFontPathReply * /* pRep */ );
 | 
					                              xGetFontPathReply * /* pRep */ );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void SGetImageReply(ClientPtr /* pClient */ ,
 | 
					 | 
				
			||||||
                           int /* size */ ,
 | 
					 | 
				
			||||||
                           xGetImageReply * /* pRep */ );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern void SListInstalledColormapsReply(ClientPtr /* pClient */ ,
 | 
					extern void SListInstalledColormapsReply(ClientPtr /* pClient */ ,
 | 
				
			||||||
                                         int /* size */ ,
 | 
					                                         int /* size */ ,
 | 
				
			||||||
                                         xListInstalledColormapsReply
 | 
					                                         xListInstalledColormapsReply
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue