Xext: panoramiX: PanoramiXGetImage() reply payload in one block
Simplify writing reply payload into just one block. This also makes further simplifications by subsequent patches easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
165eb1be2b
commit
48918f28d9
|
@ -1960,7 +1960,6 @@ PanoramiXGetImage(ClientPtr client)
|
|||
DrawablePtr pDraw;
|
||||
PanoramiXRes *draw;
|
||||
Bool isRoot;
|
||||
char *pBuf;
|
||||
int i, x, y, w, h, format, rc;
|
||||
Mask plane = 0, planemask;
|
||||
int linesDone, nlines, linesPerBuf;
|
||||
|
@ -2032,7 +2031,6 @@ PanoramiXGetImage(ClientPtr client)
|
|||
IncludeInferiors);
|
||||
}
|
||||
|
||||
|
||||
if (format == ZPixmap) {
|
||||
widthBytesLine = PixmapBytePad(w, pDraw->depth);
|
||||
length = widthBytesLine * h;
|
||||
|
@ -2046,14 +2044,6 @@ PanoramiXGetImage(ClientPtr client)
|
|||
|
||||
}
|
||||
|
||||
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)
|
||||
linesPerBuf = 0;
|
||||
else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE)
|
||||
|
@ -2063,15 +2053,9 @@ PanoramiXGetImage(ClientPtr client)
|
|||
if (linesPerBuf > h)
|
||||
linesPerBuf = h;
|
||||
}
|
||||
if (!(pBuf = calloc(linesPerBuf, widthBytesLine)))
|
||||
return BadAlloc;
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
swapl(&rep.visual);
|
||||
}
|
||||
WriteToClient(client, sizeof(rep), &rep);
|
||||
char *payload = calloc(1, length);
|
||||
char *walk = payload;
|
||||
|
||||
if (linesPerBuf == 0) {
|
||||
/* nothing to do */
|
||||
|
@ -2081,14 +2065,11 @@ PanoramiXGetImage(ClientPtr client)
|
|||
while (h - linesDone > 0) {
|
||||
nlines = min(linesPerBuf, h - linesDone);
|
||||
|
||||
if (pDraw->depth == 1)
|
||||
memset(pBuf, 0, nlines * widthBytesLine);
|
||||
|
||||
XineramaGetImageData(drawables, x, y + linesDone, w, nlines,
|
||||
format, planemask, pBuf, widthBytesLine,
|
||||
format, planemask, walk, widthBytesLine,
|
||||
isRoot);
|
||||
|
||||
WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
|
||||
walk += nlines * widthBytesLine;
|
||||
linesDone += nlines;
|
||||
}
|
||||
}
|
||||
|
@ -2099,20 +2080,30 @@ PanoramiXGetImage(ClientPtr client)
|
|||
while (h - linesDone > 0) {
|
||||
nlines = min(linesPerBuf, h - linesDone);
|
||||
|
||||
memset(pBuf, 0, nlines * widthBytesLine);
|
||||
|
||||
XineramaGetImageData(drawables, x, y + linesDone, w,
|
||||
nlines, format, plane, pBuf,
|
||||
nlines, format, plane, walk,
|
||||
widthBytesLine, isRoot);
|
||||
|
||||
WriteToClient(client, (int)(nlines * widthBytesLine), pBuf);
|
||||
|
||||
walk += nlines * widthBytesLine;
|
||||
linesDone += nlines;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(pBuf);
|
||||
|
||||
xGetImageReply xgi = {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
.visual = wVisual(((WindowPtr) pDraw)),
|
||||
.depth = pDraw->depth,
|
||||
.length = bytes_to_int32(length),
|
||||
};
|
||||
|
||||
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
|
||||
|
||||
if (length)
|
||||
WriteToClient(client, length, payload);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue